diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index eecb84c2..39ad3cec 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,16 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 + digest: sha256:d22cd2ddce65fdac6986f115563faf2fc81482b09dfbea83ac2808c92ecfdff0 diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 3e98ae70..37438d33 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -10,6 +10,5 @@ branchProtectionRules: - 'Kokoro' - 'cla/google' - 'Samples - Lint' - - 'Samples - Python 3.6' - 'Samples - Python 3.7' - 'Samples - Python 3.8' diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..f7b8344c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - main +name: docs +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docs + run: | + nox -s docs + docfx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docfx + run: | + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1e8b05c3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - main +name: lint +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + run: | + nox -s lint + - name: Run lint_setup_py + run: | + nox -s lint_setup_py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 00000000..074ee250 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=100 diff --git a/.repo-metadata.json b/.repo-metadata.json index e0aee481..3734b872 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -12,5 +12,5 @@ "api_id": "dialogflow.googleapis.com", "default_version": "v3", "codeowner_team": "@googleapis/cdpe-cloudai", - "api_shortname": "dialogflow-cx" + "api_shortname": "dialogflow" } diff --git a/CHANGELOG.md b/CHANGELOG.md index f533aaec..d036f348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [1.9.0](https://github.com/googleapis/python-dialogflow-cx/compare/v1.8.0...v1.9.0) (2022-02-26) + + +### Features + +* add api_key support ([#240](https://github.com/googleapis/python-dialogflow-cx/issues/240)) ([cf95791](https://github.com/googleapis/python-dialogflow-cx/commit/cf9579171290ecf5afeeb6a38a3504857808a4ef)) + + +### Bug Fixes + +* resolve DuplicateCredentialArgs error when using credentials_file ([f3bf440](https://github.com/googleapis/python-dialogflow-cx/commit/f3bf440a081622dfc6d8d8e385f2edb5c3e11202)) + + +### Documentation + +* add autogenerated code snippets ([2292ff5](https://github.com/googleapis/python-dialogflow-cx/commit/2292ff540aea24c3c831a5ffe1604c2c022ccb82)) + ## [1.8.0](https://github.com/googleapis/python-dialogflow-cx/compare/v1.7.0...v1.8.0) (2022-01-14) diff --git a/dialogflow-cx-v3-py.tar.gz b/dialogflow-cx-v3-py.tar.gz new file mode 100644 index 00000000..659587c7 Binary files /dev/null and b/dialogflow-cx-v3-py.tar.gz differ diff --git a/dialogflow-cx-v3beta1-py.tar.gz b/dialogflow-cx-v3beta1-py.tar.gz index a08e1877..a108ba04 100644 Binary files a/dialogflow-cx-v3beta1-py.tar.gz and b/dialogflow-cx-v3beta1-py.tar.gz differ diff --git a/docs/README.rst b/docs/README.rst new file mode 120000 index 00000000..89a01069 --- /dev/null +++ b/docs/README.rst @@ -0,0 +1 @@ +../README.rst \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 6671a47b..373b0e07 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,6 +2,9 @@ .. include:: multiprocessing.rst +This package includes clients for multiple versions of Dialogflow CX. +By default, you will get version ``dialogflowcx_v3``. + API Reference ------------- @@ -10,15 +13,22 @@ API Reference dialogflowcx_v3/services dialogflowcx_v3/types + +API Reference +------------- +.. toctree:: + :maxdepth: 2 + dialogflowcx_v3beta1/services dialogflowcx_v3beta1/types + Changelog --------- For a list of all ``google-cloud-dialogflow-cx`` releases: .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - changelog + changelog diff --git a/google/cloud/dialogflowcx/__init__.py b/google/cloud/dialogflowcx/__init__.py index 0b74f615..ba3e82d1 100644 --- a/google/cloud/dialogflowcx/__init__.py +++ b/google/cloud/dialogflowcx/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/__init__.py b/google/cloud/dialogflowcx_v3/__init__.py index e2126f7a..ab54c15f 100644 --- a/google/cloud/dialogflowcx_v3/__init__.py +++ b/google/cloud/dialogflowcx_v3/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/__init__.py b/google/cloud/dialogflowcx_v3/services/__init__.py index 4de65971..e8e1c384 100644 --- a/google/cloud/dialogflowcx_v3/services/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/agents/__init__.py b/google/cloud/dialogflowcx_v3/services/agents/__init__.py index 0501fa94..db2a1a7d 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/agents/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/agents/async_client.py b/google/cloud/dialogflowcx_v3/services/agents/async_client.py index bf345b6c..c3912488 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/agents/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -122,6 +122,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return AgentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> AgentsTransport: """Returns the transport used by the client instance. @@ -194,6 +230,27 @@ async def list_agents( r"""Returns the list of all agents in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_agents(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListAgentsRequest, dict]): The request object. The request message for @@ -221,7 +278,7 @@ async def list_agents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -274,6 +331,25 @@ async def get_agent( ) -> agent.Agent: r"""Retrieves the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetAgentRequest, dict]): The request object. The request message for @@ -310,7 +386,7 @@ async def get_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -362,6 +438,32 @@ async def create_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = client.create_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateAgentRequest, dict]): The request object. The request message for @@ -403,7 +505,7 @@ async def create_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, agent]) if request is not None and has_flattened_params: @@ -457,6 +559,31 @@ async def update_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = client.update_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateAgentRequest, dict]): The request object. The request message for @@ -499,7 +626,7 @@ async def update_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([agent, update_mask]) if request is not None and has_flattened_params: @@ -550,6 +677,22 @@ async def delete_agent( ) -> None: r"""Deletes the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + client.delete_agent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteAgentRequest, dict]): The request object. The request message for @@ -568,7 +711,7 @@ async def delete_agent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -623,6 +766,30 @@ async def export_agent( - ``response``: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_export_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ExportAgentRequest, dict]): The request object. The request message for @@ -702,6 +869,31 @@ async def restore_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.RestoreAgentRequest, dict]): The request object. The request message for @@ -775,6 +967,26 @@ async def validate_agent( validated. Please call this API after the training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = client.validate_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ValidateAgentRequest, dict]): The request object. The request message for @@ -826,6 +1038,26 @@ async def get_agent_validation_result( r"""Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetAgentValidationResultRequest, dict]): The request object. The request message for @@ -850,7 +1082,7 @@ async def get_agent_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/agents/client.py b/google/cloud/dialogflowcx_v3/services/agents/client.py index 1cff1c5c..f4473ec4 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/client.py +++ b/google/cloud/dialogflowcx_v3/services/agents/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -326,6 +326,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -376,57 +443,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, AgentsTransport): # transport is a AgentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -438,6 +470,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -462,6 +503,27 @@ def list_agents( r"""Returns the list of all agents in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_agents(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListAgentsRequest, dict]): The request object. The request message for @@ -489,7 +551,7 @@ def list_agents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -542,6 +604,25 @@ def get_agent( ) -> agent.Agent: r"""Retrieves the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetAgentRequest, dict]): The request object. The request message for @@ -578,7 +659,7 @@ def get_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -630,6 +711,32 @@ def create_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = client.create_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateAgentRequest, dict]): The request object. The request message for @@ -671,7 +778,7 @@ def create_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, agent]) if request is not None and has_flattened_params: @@ -725,6 +832,31 @@ def update_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = client.update_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateAgentRequest, dict]): The request object. The request message for @@ -767,7 +899,7 @@ def update_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([agent, update_mask]) if request is not None and has_flattened_params: @@ -818,6 +950,22 @@ def delete_agent( ) -> None: r"""Deletes the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + client.delete_agent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteAgentRequest, dict]): The request object. The request message for @@ -836,7 +984,7 @@ def delete_agent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -891,6 +1039,30 @@ def export_agent( - ``response``: [ExportAgentResponse][google.cloud.dialogflow.cx.v3.ExportAgentResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_export_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ExportAgentRequest, dict]): The request object. The request message for @@ -971,6 +1143,31 @@ def restore_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.RestoreAgentRequest, dict]): The request object. The request message for @@ -1045,6 +1242,26 @@ def validate_agent( validated. Please call this API after the training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = client.validate_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ValidateAgentRequest, dict]): The request object. The request message for @@ -1097,6 +1314,26 @@ def get_agent_validation_result( r"""Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetAgentValidationResultRequest, dict]): The request object. The request message for @@ -1121,7 +1358,7 @@ def get_agent_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/agents/pagers.py b/google/cloud/dialogflowcx_v3/services/agents/pagers.py index 0f044807..292f2dc4 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/agents/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py index ceadcd3a..703a3046 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/base.py b/google/cloud/dialogflowcx_v3/services/agents/transports/base.py index 653f9a91..b4046fe4 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/agents/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py index 7474d5c3..947a04f5 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 8911588f..853bb040 100644 --- a/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py b/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py index 028672a9..7ed8fe54 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py b/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py index 8bc872fd..d79be0ab 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -103,6 +103,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return ChangelogsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> ChangelogsTransport: """Returns the transport used by the client instance. @@ -174,6 +210,26 @@ async def list_changelogs( ) -> pagers.ListChangelogsAsyncPager: r"""Returns the list of Changelogs. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListChangelogsRequest, dict]): The request object. The request message for @@ -201,7 +257,7 @@ async def list_changelogs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -254,6 +310,25 @@ async def get_changelog( ) -> changelog.Changelog: r"""Retrieves the specified Changelog. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = client.get_changelog(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetChangelogRequest, dict]): The request object. The request message for @@ -278,7 +353,7 @@ async def get_changelog( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/client.py b/google/cloud/dialogflowcx_v3/services/changelogs/client.py index 317af699..dd267db0 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/client.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -235,6 +235,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -285,57 +352,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, ChangelogsTransport): # transport is a ChangelogsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -347,6 +379,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -370,6 +411,26 @@ def list_changelogs( ) -> pagers.ListChangelogsPager: r"""Returns the list of Changelogs. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListChangelogsRequest, dict]): The request object. The request message for @@ -397,7 +458,7 @@ def list_changelogs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -450,6 +511,25 @@ def get_changelog( ) -> changelog.Changelog: r"""Retrieves the specified Changelog. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = client.get_changelog(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetChangelogRequest, dict]): The request object. The request message for @@ -474,7 +554,7 @@ def get_changelog( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py b/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py index 60583531..eb3e695a 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py index 882554f3..34aa1f62 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py b/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py index e9ab0333..262021d6 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py index 82a2d83b..79c4ec16 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -159,8 +159,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py index 6423cc0f..865a5067 100644 --- a/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/changelogs/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -204,8 +204,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/deployments/__init__.py b/google/cloud/dialogflowcx_v3/services/deployments/__init__.py index 59dd17bb..5a5d1148 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/deployments/async_client.py b/google/cloud/dialogflowcx_v3/services/deployments/async_client.py index b2080ff2..c001c373 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -113,6 +113,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return DeploymentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> DeploymentsTransport: """Returns the transport used by the client instance. @@ -185,6 +221,27 @@ async def list_deployments( r"""Returns the list of all deployments in the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListDeploymentsRequest, dict]): The request object. The request message for @@ -214,7 +271,7 @@ async def list_deployments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -268,6 +325,26 @@ async def get_deployment( r"""Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetDeploymentRequest, dict]): The request object. The request message for @@ -299,7 +376,7 @@ async def get_deployment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/deployments/client.py b/google/cloud/dialogflowcx_v3/services/deployments/client.py index e7e31520..dadd5a28 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/client.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -303,6 +303,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -353,57 +420,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, DeploymentsTransport): # transport is a DeploymentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -415,6 +447,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -439,6 +480,27 @@ def list_deployments( r"""Returns the list of all deployments in the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListDeploymentsRequest, dict]): The request object. The request message for @@ -468,7 +530,7 @@ def list_deployments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -522,6 +584,26 @@ def get_deployment( r"""Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3.Deployment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetDeploymentRequest, dict]): The request object. The request message for @@ -553,7 +635,7 @@ def get_deployment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/deployments/pagers.py b/google/cloud/dialogflowcx_v3/services/deployments/pagers.py index 0c7a064f..8736fc12 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py index 78292dd3..f902c685 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py b/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py index 6519d968..d8359f19 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py index 800c9aec..d1a280eb 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -159,8 +159,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py index 1ed430ad..6f9684a0 100644 --- a/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/deployments/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -204,8 +204,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py b/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py index 77cd53e9..b0093027 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 46bcecb1..b9674f6f 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -106,6 +106,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return EntityTypesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> EntityTypesTransport: """Returns the transport used by the client instance. @@ -178,6 +214,27 @@ async def list_entity_types( r"""Returns the list of all entity types in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListEntityTypesRequest, dict]): The request object. The request message for @@ -206,7 +263,7 @@ async def list_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -259,6 +316,25 @@ async def get_entity_type( ) -> entity_type.EntityType: r"""Retrieves the specified entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetEntityTypeRequest, dict]): The request object. The request message for @@ -315,7 +391,7 @@ async def get_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -367,6 +443,31 @@ async def create_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = client.create_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateEntityTypeRequest, dict]): The request object. The request message for @@ -428,7 +529,7 @@ async def create_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, entity_type]) if request is not None and has_flattened_params: @@ -482,6 +583,30 @@ async def update_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = client.update_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateEntityTypeRequest, dict]): The request object. The request message for @@ -543,7 +668,7 @@ async def update_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([entity_type, update_mask]) if request is not None and has_flattened_params: @@ -598,6 +723,23 @@ async def delete_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteEntityTypeRequest, dict]): The request object. The request message for @@ -616,7 +758,7 @@ async def delete_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/client.py b/google/cloud/dialogflowcx_v3/services/entity_types/client.py index 344cebb1..41d69d1b 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/client.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -238,6 +238,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -288,57 +355,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, EntityTypesTransport): # transport is a EntityTypesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -350,6 +382,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -374,6 +415,27 @@ def list_entity_types( r"""Returns the list of all entity types in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListEntityTypesRequest, dict]): The request object. The request message for @@ -402,7 +464,7 @@ def list_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -455,6 +517,25 @@ def get_entity_type( ) -> entity_type.EntityType: r"""Retrieves the specified entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetEntityTypeRequest, dict]): The request object. The request message for @@ -511,7 +592,7 @@ def get_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -563,6 +644,31 @@ def create_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = client.create_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateEntityTypeRequest, dict]): The request object. The request message for @@ -624,7 +730,7 @@ def create_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, entity_type]) if request is not None and has_flattened_params: @@ -678,6 +784,30 @@ def update_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = client.update_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateEntityTypeRequest, dict]): The request object. The request message for @@ -739,7 +869,7 @@ def update_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([entity_type, update_mask]) if request is not None and has_flattened_params: @@ -794,6 +924,23 @@ def delete_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteEntityTypeRequest, dict]): The request object. The request message for @@ -812,7 +959,7 @@ def delete_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py b/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py index 609bf782..900a774d 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py index 07ea82e1..2a22d664 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 b11b3f8c..cbce6c86 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 2590fb7c..14920625 100644 --- a/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 1ace4866..b0bc3cda 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/environments/__init__.py b/google/cloud/dialogflowcx_v3/services/environments/__init__.py index 0c2be948..22833765 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/environments/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/environments/async_client.py b/google/cloud/dialogflowcx_v3/services/environments/async_client.py index eda7e971..9bbba78a 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/environments/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -124,6 +124,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return EnvironmentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> EnvironmentsTransport: """Returns the transport used by the client instance. @@ -196,6 +232,27 @@ async def list_environments( r"""Returns the list of all environments in the specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_environments(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListEnvironmentsRequest, dict]): The request object. The request message for @@ -225,7 +282,7 @@ async def list_environments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -279,6 +336,26 @@ async def get_environment( r"""Retrieves the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = client.get_environment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetEnvironmentRequest, dict]): The request object. The request message for @@ -318,7 +395,7 @@ async def get_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -378,6 +455,35 @@ async def create_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateEnvironmentRequest, dict]): The request object. The request message for @@ -422,7 +528,7 @@ async def create_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, environment]) if request is not None and has_flattened_params: @@ -491,6 +597,34 @@ async def update_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateEnvironmentRequest, dict]): The request object. The request message for @@ -531,7 +665,7 @@ async def update_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([environment, update_mask]) if request is not None and has_flattened_params: @@ -591,6 +725,23 @@ async def delete_environment( r"""Deletes the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + client.delete_environment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteEnvironmentRequest, dict]): The request object. The request message for @@ -611,7 +762,7 @@ async def delete_environment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -658,6 +809,27 @@ async def lookup_environment_history( r"""Looks up the history of the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryRequest, dict]): The request object. The request message for @@ -686,7 +858,7 @@ async def lookup_environment_history( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -749,6 +921,30 @@ async def run_continuous_test( - ``response``: [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.RunContinuousTestRequest, dict]): The request object. The request message for @@ -814,6 +1010,27 @@ async def list_continuous_test_results( r"""Fetches a list of continuous test results for a given environment. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsRequest, dict]): The request object. The request message for @@ -841,7 +1058,7 @@ async def list_continuous_test_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -904,6 +1121,31 @@ async def deploy_flow( - ``response``: [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeployFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3/services/environments/client.py b/google/cloud/dialogflowcx_v3/services/environments/client.py index 18c0e14f..da6eaa6a 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/client.py +++ b/google/cloud/dialogflowcx_v3/services/environments/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -324,6 +324,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -374,57 +441,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, EnvironmentsTransport): # transport is a EnvironmentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -436,6 +468,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -460,6 +501,27 @@ def list_environments( r"""Returns the list of all environments in the specified [Agent][google.cloud.dialogflow.cx.v3.Agent]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_environments(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListEnvironmentsRequest, dict]): The request object. The request message for @@ -489,7 +551,7 @@ def list_environments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -543,6 +605,26 @@ def get_environment( r"""Retrieves the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = client.get_environment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetEnvironmentRequest, dict]): The request object. The request message for @@ -582,7 +664,7 @@ def get_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -642,6 +724,35 @@ def create_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateEnvironmentRequest, dict]): The request object. The request message for @@ -686,7 +797,7 @@ def create_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, environment]) if request is not None and has_flattened_params: @@ -755,6 +866,34 @@ def update_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateEnvironmentRequest, dict]): The request object. The request message for @@ -795,7 +934,7 @@ def update_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([environment, update_mask]) if request is not None and has_flattened_params: @@ -855,6 +994,23 @@ def delete_environment( r"""Deletes the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + client.delete_environment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteEnvironmentRequest, dict]): The request object. The request message for @@ -875,7 +1031,7 @@ def delete_environment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -922,6 +1078,27 @@ def lookup_environment_history( r"""Looks up the history of the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.LookupEnvironmentHistoryRequest, dict]): The request object. The request message for @@ -950,7 +1127,7 @@ def lookup_environment_history( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1015,6 +1192,30 @@ def run_continuous_test( - ``response``: [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3.RunContinuousTestResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.RunContinuousTestRequest, dict]): The request object. The request message for @@ -1081,6 +1282,27 @@ def list_continuous_test_results( r"""Fetches a list of continuous test results for a given environment. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListContinuousTestResultsRequest, dict]): The request object. The request message for @@ -1108,7 +1330,7 @@ def list_continuous_test_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1173,6 +1395,31 @@ def deploy_flow( - ``response``: [DeployFlowResponse][google.cloud.dialogflow.cx.v3.DeployFlowResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeployFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3/services/environments/pagers.py b/google/cloud/dialogflowcx_v3/services/environments/pagers.py index 62c7b95e..22f4e847 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/environments/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py index c72efee4..0ecefb61 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/environments/transports/base.py b/google/cloud/dialogflowcx_v3/services/environments/transports/base.py index b3a6d2da..46b34e6d 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/environments/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py index dcd2f28e..54b87880 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 378f1cda..81a0e563 100644 --- a/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3/services/experiments/__init__.py b/google/cloud/dialogflowcx_v3/services/experiments/__init__.py index 560b13da..550aae89 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/experiments/async_client.py b/google/cloud/dialogflowcx_v3/services/experiments/async_client.py index c8516296..02af6496 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -110,6 +110,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return ExperimentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> ExperimentsTransport: """Returns the transport used by the client instance. @@ -182,6 +218,27 @@ async def list_experiments( r"""Returns the list of all experiments in the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListExperimentsRequest, dict]): The request object. The request message for @@ -211,7 +268,7 @@ async def list_experiments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -265,6 +322,26 @@ async def get_experiment( r"""Retrieves the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.get_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetExperimentRequest, dict]): The request object. The request message for @@ -291,7 +368,7 @@ async def get_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -342,6 +419,30 @@ async def create_experiment( specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = client.create_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateExperimentRequest, dict]): The request object. The request message for @@ -375,7 +476,7 @@ async def create_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, experiment]) if request is not None and has_flattened_params: @@ -426,6 +527,29 @@ async def update_experiment( r"""Updates the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = client.update_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateExperimentRequest, dict]): The request object. The request message for @@ -455,7 +579,7 @@ async def update_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([experiment, update_mask]) if request is not None and has_flattened_params: @@ -507,6 +631,23 @@ async def delete_experiment( r"""Deletes the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + client.delete_experiment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteExperimentRequest, dict]): The request object. The request message for @@ -527,7 +668,7 @@ async def delete_experiment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -575,6 +716,26 @@ async def start_experiment( [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only changes the state of experiment from PENDING to RUNNING. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.start_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.StartExperimentRequest, dict]): The request object. The request message for @@ -600,7 +761,7 @@ async def start_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -649,6 +810,26 @@ async def stop_experiment( [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only changes the state of experiment from RUNNING to DONE. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.stop_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.StopExperimentRequest, dict]): The request object. The request message for @@ -674,7 +855,7 @@ async def stop_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/experiments/client.py b/google/cloud/dialogflowcx_v3/services/experiments/client.py index 46142b1a..616acadf 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/client.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -262,6 +262,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -312,57 +379,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, ExperimentsTransport): # transport is a ExperimentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -374,6 +406,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -398,6 +439,27 @@ def list_experiments( r"""Returns the list of all experiments in the specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListExperimentsRequest, dict]): The request object. The request message for @@ -427,7 +489,7 @@ def list_experiments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -481,6 +543,26 @@ def get_experiment( r"""Retrieves the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.get_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetExperimentRequest, dict]): The request object. The request message for @@ -507,7 +589,7 @@ def get_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -558,6 +640,30 @@ def create_experiment( specified [Environment][google.cloud.dialogflow.cx.v3.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = client.create_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateExperimentRequest, dict]): The request object. The request message for @@ -591,7 +697,7 @@ def create_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, experiment]) if request is not None and has_flattened_params: @@ -642,6 +748,29 @@ def update_experiment( r"""Updates the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = client.update_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateExperimentRequest, dict]): The request object. The request message for @@ -671,7 +800,7 @@ def update_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([experiment, update_mask]) if request is not None and has_flattened_params: @@ -723,6 +852,23 @@ def delete_experiment( r"""Deletes the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + client.delete_experiment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteExperimentRequest, dict]): The request object. The request message for @@ -743,7 +889,7 @@ def delete_experiment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -791,6 +937,26 @@ def start_experiment( [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only changes the state of experiment from PENDING to RUNNING. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.start_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.StartExperimentRequest, dict]): The request object. The request message for @@ -816,7 +982,7 @@ def start_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -865,6 +1031,26 @@ def stop_experiment( [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only changes the state of experiment from RUNNING to DONE. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.stop_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.StopExperimentRequest, dict]): The request object. The request message for @@ -890,7 +1076,7 @@ def stop_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/experiments/pagers.py b/google/cloud/dialogflowcx_v3/services/experiments/pagers.py index 0b39243c..2cb60337 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py index 3be44737..3a6183c3 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py b/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py index 054b3ebd..6d95ec78 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py index f575a94f..28e39fbc 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 a72a7e17..51ea5a22 100644 --- a/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/experiments/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/flows/__init__.py b/google/cloud/dialogflowcx_v3/services/flows/__init__.py index 03ec82a2..184d3531 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/flows/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/flows/async_client.py b/google/cloud/dialogflowcx_v3/services/flows/async_client.py index 9af2029a..3c826bcc 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/flows/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -119,6 +119,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return FlowsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> FlowsTransport: """Returns the transport used by the client instance. @@ -195,6 +231,30 @@ async def create_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = client.create_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateFlowRequest, dict]): The request object. The request message for @@ -245,7 +305,7 @@ async def create_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, flow]) if request is not None and has_flattened_params: @@ -294,6 +354,22 @@ async def delete_flow( ) -> None: r"""Deletes a specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + client.delete_flow(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteFlowRequest, dict]): The request object. The request message for @@ -312,7 +388,7 @@ async def delete_flow( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -358,6 +434,26 @@ async def list_flows( ) -> pagers.ListFlowsAsyncPager: r"""Returns the list of all flows in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_flows(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListFlowsRequest, dict]): The request object. The request message for @@ -385,7 +481,7 @@ async def list_flows( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -438,6 +534,25 @@ async def get_flow( ) -> flow.Flow: r"""Retrieves the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetFlowRequest, dict]): The request object. The response message for @@ -483,7 +598,7 @@ async def get_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -535,6 +650,29 @@ async def update_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = client.update_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateFlowRequest, dict]): The request object. The request message for @@ -586,7 +724,7 @@ async def update_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([flow, update_mask]) if request is not None and has_flattened_params: @@ -652,6 +790,30 @@ async def train_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_train_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.TrainFlowRequest, dict]): The request object. The request message for @@ -689,7 +851,7 @@ async def train_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -746,6 +908,26 @@ async def validate_flow( training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = client.validate_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ValidateFlowRequest, dict]): The request object. The request message for @@ -797,6 +979,26 @@ async def get_flow_validation_result( r"""Gets the latest flow validation result. Flow validation is performed when ValidateFlow is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetFlowValidationResultRequest, dict]): The request object. The request message for @@ -821,7 +1023,7 @@ async def get_flow_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -882,6 +1084,31 @@ async def import_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_import_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ImportFlowRequest, dict]): The request object. The request message for @@ -956,6 +1183,30 @@ async def export_flow( Note that resources (e.g. intents, entities, webhooks) that the flow references will also be exported. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_export_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ExportFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3/services/flows/client.py b/google/cloud/dialogflowcx_v3/services/flows/client.py index 066385a9..8af6aa1a 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/client.py +++ b/google/cloud/dialogflowcx_v3/services/flows/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -331,6 +331,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -381,57 +448,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, FlowsTransport): # transport is a FlowsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -443,6 +475,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -471,6 +512,30 @@ def create_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = client.create_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateFlowRequest, dict]): The request object. The request message for @@ -521,7 +586,7 @@ def create_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, flow]) if request is not None and has_flattened_params: @@ -570,6 +635,22 @@ def delete_flow( ) -> None: r"""Deletes a specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + client.delete_flow(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteFlowRequest, dict]): The request object. The request message for @@ -588,7 +669,7 @@ def delete_flow( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -634,6 +715,26 @@ def list_flows( ) -> pagers.ListFlowsPager: r"""Returns the list of all flows in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_flows(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListFlowsRequest, dict]): The request object. The request message for @@ -661,7 +762,7 @@ def list_flows( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -714,6 +815,25 @@ def get_flow( ) -> flow.Flow: r"""Retrieves the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetFlowRequest, dict]): The request object. The response message for @@ -759,7 +879,7 @@ def get_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -811,6 +931,29 @@ def update_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = client.update_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateFlowRequest, dict]): The request object. The request message for @@ -862,7 +1005,7 @@ def update_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([flow, update_mask]) if request is not None and has_flattened_params: @@ -928,6 +1071,30 @@ def train_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_train_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.TrainFlowRequest, dict]): The request object. The request message for @@ -965,7 +1132,7 @@ def train_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1022,6 +1189,26 @@ def validate_flow( training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = client.validate_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ValidateFlowRequest, dict]): The request object. The request message for @@ -1074,6 +1261,26 @@ def get_flow_validation_result( r"""Gets the latest flow validation result. Flow validation is performed when ValidateFlow is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetFlowValidationResultRequest, dict]): The request object. The request message for @@ -1098,7 +1305,7 @@ def get_flow_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1161,6 +1368,31 @@ def import_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_import_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ImportFlowRequest, dict]): The request object. The request message for @@ -1236,6 +1468,30 @@ def export_flow( Note that resources (e.g. intents, entities, webhooks) that the flow references will also be exported. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_export_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ExportFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3/services/flows/pagers.py b/google/cloud/dialogflowcx_v3/services/flows/pagers.py index d6b16e5d..9efc7902 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/flows/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py index f2970e47..d27c76de 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/flows/transports/base.py b/google/cloud/dialogflowcx_v3/services/flows/transports/base.py index ff4604ec..02a495dc 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/flows/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py index 49ea9caa..30c83c57 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 c3141db7..a39c294d 100644 --- a/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3/services/intents/__init__.py b/google/cloud/dialogflowcx_v3/services/intents/__init__.py index 5a2c263c..283553c4 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/intents/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/intents/async_client.py b/google/cloud/dialogflowcx_v3/services/intents/async_client.py index f14dde7b..1b6120c7 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/intents/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -104,6 +104,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return IntentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> IntentsTransport: """Returns the transport used by the client instance. @@ -176,6 +212,27 @@ async def list_intents( r"""Returns the list of all intents in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_intents(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListIntentsRequest, dict]): The request object. The request message for @@ -203,7 +260,7 @@ async def list_intents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -256,6 +313,25 @@ async def get_intent( ) -> intent.Intent: r"""Retrieves the specified intent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = client.get_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetIntentRequest, dict]): The request object. The request message for @@ -285,7 +361,7 @@ async def get_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -337,6 +413,30 @@ async def create_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = client.create_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateIntentRequest, dict]): The request object. The request message for @@ -371,7 +471,7 @@ async def create_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, intent]) if request is not None and has_flattened_params: @@ -425,6 +525,29 @@ async def update_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = client.update_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateIntentRequest, dict]): The request object. The request message for @@ -460,7 +583,7 @@ async def update_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([intent, update_mask]) if request is not None and has_flattened_params: @@ -515,6 +638,23 @@ async def delete_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + client.delete_intent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteIntentRequest, dict]): The request object. The request message for @@ -533,7 +673,7 @@ async def delete_intent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/intents/client.py b/google/cloud/dialogflowcx_v3/services/intents/client.py index e3af3a6f..452e74ce 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/client.py +++ b/google/cloud/dialogflowcx_v3/services/intents/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -254,6 +254,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -304,57 +371,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, IntentsTransport): # transport is a IntentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -366,6 +398,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -390,6 +431,27 @@ def list_intents( r"""Returns the list of all intents in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_intents(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListIntentsRequest, dict]): The request object. The request message for @@ -417,7 +479,7 @@ def list_intents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -470,6 +532,25 @@ def get_intent( ) -> intent.Intent: r"""Retrieves the specified intent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = client.get_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetIntentRequest, dict]): The request object. The request message for @@ -499,7 +580,7 @@ def get_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -551,6 +632,30 @@ def create_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = client.create_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateIntentRequest, dict]): The request object. The request message for @@ -585,7 +690,7 @@ def create_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, intent]) if request is not None and has_flattened_params: @@ -639,6 +744,29 @@ def update_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = client.update_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateIntentRequest, dict]): The request object. The request message for @@ -674,7 +802,7 @@ def update_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([intent, update_mask]) if request is not None and has_flattened_params: @@ -729,6 +857,23 @@ def delete_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + client.delete_intent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteIntentRequest, dict]): The request object. The request message for @@ -747,7 +892,7 @@ def delete_intent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/intents/pagers.py b/google/cloud/dialogflowcx_v3/services/intents/pagers.py index cc6fa8ea..fd60723d 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/intents/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py index 974a5810..876b5cd1 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/intents/transports/base.py b/google/cloud/dialogflowcx_v3/services/intents/transports/base.py index ef0cab33..2b524b52 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/intents/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py index 7bc18d06..fae445dc 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 b7fe2953..e4013cc5 100644 --- a/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/pages/__init__.py b/google/cloud/dialogflowcx_v3/services/pages/__init__.py index c5a52656..5a89d061 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/pages/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/pages/async_client.py b/google/cloud/dialogflowcx_v3/services/pages/async_client.py index 61a865e5..b010adc8 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/pages/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -111,6 +111,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return PagesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> PagesTransport: """Returns the transport used by the client instance. @@ -182,6 +218,26 @@ async def list_pages( ) -> pagers.ListPagesAsyncPager: r"""Returns the list of all pages in the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_pages(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListPagesRequest, dict]): The request object. The request message for @@ -209,7 +265,7 @@ async def list_pages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -262,6 +318,25 @@ async def get_page( ) -> page.Page: r"""Retrieves the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetPageRequest( + name="name_value", + ) + + # Make the request + response = client.get_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetPageRequest, dict]): The request object. The request message for @@ -306,7 +381,7 @@ async def get_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -358,6 +433,30 @@ async def create_page( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = client.create_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreatePageRequest, dict]): The request object. The request message for @@ -407,7 +506,7 @@ async def create_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, page]) if request is not None and has_flattened_params: @@ -461,6 +560,29 @@ async def update_page( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdatePageRequest( + page=page, + ) + + # Make the request + response = client.update_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdatePageRequest, dict]): The request object. The request message for @@ -511,7 +633,7 @@ async def update_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([page, update_mask]) if request is not None and has_flattened_params: @@ -566,6 +688,23 @@ async def delete_page( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeletePageRequest( + name="name_value", + ) + + # Make the request + client.delete_page(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeletePageRequest, dict]): The request object. The request message for @@ -584,7 +723,7 @@ async def delete_page( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/pages/client.py b/google/cloud/dialogflowcx_v3/services/pages/client.py index beac74ec..d2b709ba 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/client.py +++ b/google/cloud/dialogflowcx_v3/services/pages/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -325,6 +325,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -375,57 +442,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, PagesTransport): # transport is a PagesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -437,6 +469,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -460,6 +501,26 @@ def list_pages( ) -> pagers.ListPagesPager: r"""Returns the list of all pages in the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_pages(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListPagesRequest, dict]): The request object. The request message for @@ -487,7 +548,7 @@ def list_pages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -540,6 +601,25 @@ def get_page( ) -> page.Page: r"""Retrieves the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetPageRequest( + name="name_value", + ) + + # Make the request + response = client.get_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetPageRequest, dict]): The request object. The request message for @@ -584,7 +664,7 @@ def get_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -636,6 +716,30 @@ def create_page( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = client.create_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreatePageRequest, dict]): The request object. The request message for @@ -685,7 +789,7 @@ def create_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, page]) if request is not None and has_flattened_params: @@ -739,6 +843,29 @@ def update_page( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdatePageRequest( + page=page, + ) + + # Make the request + response = client.update_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdatePageRequest, dict]): The request object. The request message for @@ -789,7 +916,7 @@ def update_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([page, update_mask]) if request is not None and has_flattened_params: @@ -844,6 +971,23 @@ def delete_page( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeletePageRequest( + name="name_value", + ) + + # Make the request + client.delete_page(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeletePageRequest, dict]): The request object. The request message for @@ -862,7 +1006,7 @@ def delete_page( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/pages/pagers.py b/google/cloud/dialogflowcx_v3/services/pages/pagers.py index ad396406..b68d59e7 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/pages/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py index fff7089d..fd23f06e 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/pages/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/pages/transports/base.py b/google/cloud/dialogflowcx_v3/services/pages/transports/base.py index 60e6c8b2..6059ee9a 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/pages/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py index 5e37f69e..7376b22f 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -160,8 +160,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 f8798d95..20dbb5e6 100644 --- a/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/pages/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -205,8 +205,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py index d8b471f4..8d770740 100644 --- a/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py index fb228194..57442169 100644 --- a/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -130,6 +130,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SecuritySettingsServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SecuritySettingsServiceTransport: """Returns the transport used by the client instance. @@ -205,6 +241,30 @@ async def create_security_settings( ) -> gcdc_security_settings.SecuritySettings: r"""Create security settings in the specified location. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = client.create_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateSecuritySettingsRequest, dict]): The request object. The request message for @@ -242,7 +302,7 @@ async def create_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, security_settings]) if request is not None and has_flattened_params: @@ -293,6 +353,26 @@ async def get_security_settings( [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. The returned settings may be stale by up to 1 minute. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetSecuritySettingsRequest, dict]): The request object. The request message for @@ -321,7 +401,7 @@ async def get_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -372,6 +452,30 @@ async def update_security_settings( r"""Updates the specified [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = client.update_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateSecuritySettingsRequest, dict]): The request object. The request message for @@ -408,7 +512,7 @@ async def update_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([security_settings, update_mask]) if request is not None and has_flattened_params: @@ -460,6 +564,27 @@ async def list_security_settings( r"""Returns the list of all security settings in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListSecuritySettingsRequest, dict]): The request object. The request message for @@ -488,7 +613,7 @@ async def list_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -542,6 +667,23 @@ async def delete_security_settings( r"""Deletes the specified [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + client.delete_security_settings(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteSecuritySettingsRequest, dict]): The request object. The request message for @@ -562,7 +704,7 @@ async def delete_security_settings( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py index f2fda375..c18f178e 100644 --- a/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py +++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -282,6 +282,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -332,57 +399,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SecuritySettingsServiceTransport): # transport is a SecuritySettingsServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -394,6 +426,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -420,6 +461,30 @@ def create_security_settings( ) -> gcdc_security_settings.SecuritySettings: r"""Create security settings in the specified location. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = client.create_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateSecuritySettingsRequest, dict]): The request object. The request message for @@ -457,7 +522,7 @@ def create_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, security_settings]) if request is not None and has_flattened_params: @@ -510,6 +575,26 @@ def get_security_settings( [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. The returned settings may be stale by up to 1 minute. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetSecuritySettingsRequest, dict]): The request object. The request message for @@ -538,7 +623,7 @@ def get_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -589,6 +674,30 @@ def update_security_settings( r"""Updates the specified [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = client.update_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateSecuritySettingsRequest, dict]): The request object. The request message for @@ -625,7 +734,7 @@ def update_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([security_settings, update_mask]) if request is not None and has_flattened_params: @@ -679,6 +788,27 @@ def list_security_settings( r"""Returns the list of all security settings in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListSecuritySettingsRequest, dict]): The request object. The request message for @@ -707,7 +837,7 @@ def list_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -761,6 +891,23 @@ def delete_security_settings( r"""Deletes the specified [SecuritySettings][google.cloud.dialogflow.cx.v3.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + client.delete_security_settings(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteSecuritySettingsRequest, dict]): The request object. The request message for @@ -781,7 +928,7 @@ def delete_security_settings( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py index 245e82e6..8aaa367a 100644 --- a/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py index 8f3a8c8b..bcf597b1 100644 --- a/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/security_settings_service/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 9609fe3d..6df0a8cd 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 995205ab..fcfb48b5 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -162,8 +162,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 714d48d6..ac801be1 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -207,8 +207,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py index cbd406b4..a8d58e17 100644 --- a/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py index 1a254f50..f8b9a830 100644 --- a/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -117,6 +117,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SessionEntityTypesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SessionEntityTypesTransport: """Returns the transport used by the client instance. @@ -190,6 +226,27 @@ async def list_session_entity_types( r"""Returns the list of all session entity types in the specified session. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesRequest, dict]): The request object. The request message for @@ -222,7 +279,7 @@ async def list_session_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -275,6 +332,25 @@ async def get_session_entity_type( ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetSessionEntityTypeRequest, dict]): The request object. The request message for @@ -317,7 +393,7 @@ async def get_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -367,6 +443,32 @@ async def create_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Creates a session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.create_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -417,7 +519,7 @@ async def create_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, session_entity_type]) if request is not None and has_flattened_params: @@ -469,6 +571,31 @@ async def update_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.update_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -518,7 +645,7 @@ async def update_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([session_entity_type, update_mask]) if request is not None and has_flattened_params: @@ -569,6 +696,22 @@ async def delete_session_entity_type( ) -> None: r"""Deletes the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_session_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteSessionEntityTypeRequest, dict]): The request object. The request message for @@ -592,7 +735,7 @@ async def delete_session_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py index a4e755f4..e8e6ff4d 100644 --- a/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py +++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -249,6 +249,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -299,57 +366,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SessionEntityTypesTransport): # transport is a SessionEntityTypesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -361,6 +393,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -385,6 +426,27 @@ def list_session_entity_types( r"""Returns the list of all session entity types in the specified session. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListSessionEntityTypesRequest, dict]): The request object. The request message for @@ -417,7 +479,7 @@ def list_session_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -472,6 +534,25 @@ def get_session_entity_type( ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetSessionEntityTypeRequest, dict]): The request object. The request message for @@ -514,7 +595,7 @@ def get_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -564,6 +645,32 @@ def create_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Creates a session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.create_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -614,7 +721,7 @@ def create_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, session_entity_type]) if request is not None and has_flattened_params: @@ -670,6 +777,31 @@ def update_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.update_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -719,7 +851,7 @@ def update_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([session_entity_type, update_mask]) if request is not None and has_flattened_params: @@ -774,6 +906,22 @@ def delete_session_entity_type( ) -> None: r"""Deletes the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_session_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteSessionEntityTypeRequest, dict]): The request object. The request message for @@ -797,7 +945,7 @@ def delete_session_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py index 9cfcbd49..ab1472de 100644 --- a/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py index 633fd32c..44e2a8d4 100644 --- a/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/session_entity_types/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 4d697146..659fe3d6 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 4bf79335..2ebaff13 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 a3d83c09..0c22f8a2 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/sessions/__init__.py b/google/cloud/dialogflowcx_v3/services/sessions/__init__.py index 0adeafb9..49b86a28 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/sessions/async_client.py b/google/cloud/dialogflowcx_v3/services/sessions/async_client.py index d204dba7..1e2b9873 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import re from typing import ( Dict, + Optional, AsyncIterable, Awaitable, AsyncIterator, @@ -134,6 +135,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SessionsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SessionsTransport: """Returns the transport used by the client instance. @@ -211,6 +248,31 @@ async def detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.detect_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DetectIntentRequest, dict]): The request object. The request to detect user's intent. @@ -275,6 +337,41 @@ def streaming_detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + for response in stream: + print(response) + Args: requests (AsyncIterator[`google.cloud.dialogflowcx_v3.types.StreamingDetectIntentRequest`]): The request object AsyncIterator. The top-level message sent by the @@ -379,6 +476,31 @@ async def match_intent( r"""Returns preliminary intent match results, doesn't change the session status. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_match_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.match_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.MatchIntentRequest, dict]): The request object. Request of [MatchIntent][]. @@ -431,6 +553,25 @@ async def fulfill_intent( [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. Otherwise, the behavior is undefined. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.FulfillIntentRequest( + ) + + # Make the request + response = client.fulfill_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.FulfillIntentRequest, dict]): The request object. Request of [FulfillIntent][] diff --git a/google/cloud/dialogflowcx_v3/services/sessions/client.py b/google/cloud/dialogflowcx_v3/services/sessions/client.py index 63fe2f45..563aacfb 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/client.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -383,6 +383,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -433,57 +500,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SessionsTransport): # transport is a SessionsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -495,6 +527,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -524,6 +565,31 @@ def detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.detect_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DetectIntentRequest, dict]): The request object. The request to detect user's intent. @@ -580,6 +646,41 @@ def streaming_detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + for response in stream: + print(response) + Args: requests (Iterator[google.cloud.dialogflowcx_v3.types.StreamingDetectIntentRequest]): The request object iterator. The top-level message sent by the @@ -680,6 +781,31 @@ def match_intent( r"""Returns preliminary intent match results, doesn't change the session status. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_match_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.match_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.MatchIntentRequest, dict]): The request object. Request of [MatchIntent][]. @@ -733,6 +859,25 @@ def fulfill_intent( [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse]. Otherwise, the behavior is undefined. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.FulfillIntentRequest( + ) + + # Make the request + response = client.fulfill_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.FulfillIntentRequest, dict]): The request object. Request of [FulfillIntent][] diff --git a/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py index db0f7d04..ce00ff37 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py b/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py index ed7d5548..7732b6b5 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py index d5ff971c..255c577a 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 82ef0d17..17da4bd3 100644 --- a/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/sessions/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py b/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py index 359c8900..f9c1fe81 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py b/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py index fdbdff81..90f98f35 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -132,6 +132,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return TestCasesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> TestCasesTransport: """Returns the transport used by the client instance. @@ -203,6 +239,26 @@ async def list_test_cases( ) -> pagers.ListTestCasesAsyncPager: r"""Fetches a list of test cases for a given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListTestCasesRequest, dict]): The request object. The request message for @@ -230,7 +286,7 @@ async def list_test_cases( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -283,6 +339,23 @@ async def batch_delete_test_cases( ) -> None: r"""Batch deletes test cases. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + client.batch_delete_test_cases(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.BatchDeleteTestCasesRequest, dict]): The request object. The request message for @@ -301,7 +374,7 @@ async def batch_delete_test_cases( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -347,6 +420,25 @@ async def get_test_case( ) -> test_case.TestCase: r"""Gets a test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetTestCaseRequest, dict]): The request object. The request message for @@ -369,7 +461,7 @@ async def get_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -417,6 +509,29 @@ async def create_test_case( ) -> gcdc_test_case.TestCase: r"""Creates a test case for the given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = client.create_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateTestCaseRequest, dict]): The request object. The request message for @@ -444,7 +559,7 @@ async def create_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, test_case]) if request is not None and has_flattened_params: @@ -494,6 +609,28 @@ async def update_test_case( ) -> gcdc_test_case.TestCase: r"""Updates the specified test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = client.update_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateTestCaseRequest, dict]): The request object. The request message for @@ -525,7 +662,7 @@ async def update_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([test_case, update_mask]) if request is not None and has_flattened_params: @@ -585,6 +722,30 @@ async def run_test_case( - ``response``: [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.RunTestCaseRequest, dict]): The request object. The request message for @@ -656,6 +817,31 @@ async def batch_run_test_cases( - ``response``: [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.BatchRunTestCasesRequest, dict]): The request object. The request message for @@ -717,6 +903,26 @@ async def calculate_coverage( ) -> test_case.CalculateCoverageResponse: r"""Calculates the test coverage for an agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = client.calculate_coverage(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CalculateCoverageRequest, dict]): The request object. The request message for @@ -779,6 +985,31 @@ async def import_test_cases( - ``response``: [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ImportTestCasesRequest, dict]): The request object. The request message for @@ -852,6 +1083,31 @@ async def export_test_cases( - ``response``: [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ExportTestCasesRequest, dict]): The request object. The request message for @@ -914,6 +1170,26 @@ async def list_test_case_results( ) -> pagers.ListTestCaseResultsAsyncPager: r"""Fetches a list of results for a given test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListTestCaseResultsRequest, dict]): The request object. The request message for @@ -943,7 +1219,7 @@ async def list_test_case_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -996,6 +1272,25 @@ async def get_test_case_result( ) -> test_case.TestCaseResult: r"""Gets a test case result. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetTestCaseResultRequest, dict]): The request object. The request message for @@ -1020,7 +1315,7 @@ async def get_test_case_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/client.py b/google/cloud/dialogflowcx_v3/services/test_cases/client.py index a1bebc83..6ce90f7c 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/client.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -402,6 +402,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -452,57 +519,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, TestCasesTransport): # transport is a TestCasesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -514,6 +546,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -537,6 +578,26 @@ def list_test_cases( ) -> pagers.ListTestCasesPager: r"""Fetches a list of test cases for a given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListTestCasesRequest, dict]): The request object. The request message for @@ -564,7 +625,7 @@ def list_test_cases( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -617,6 +678,23 @@ def batch_delete_test_cases( ) -> None: r"""Batch deletes test cases. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + client.batch_delete_test_cases(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.BatchDeleteTestCasesRequest, dict]): The request object. The request message for @@ -635,7 +713,7 @@ def batch_delete_test_cases( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -681,6 +759,25 @@ def get_test_case( ) -> test_case.TestCase: r"""Gets a test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetTestCaseRequest, dict]): The request object. The request message for @@ -703,7 +800,7 @@ def get_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -751,6 +848,29 @@ def create_test_case( ) -> gcdc_test_case.TestCase: r"""Creates a test case for the given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = client.create_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateTestCaseRequest, dict]): The request object. The request message for @@ -778,7 +898,7 @@ def create_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, test_case]) if request is not None and has_flattened_params: @@ -828,6 +948,28 @@ def update_test_case( ) -> gcdc_test_case.TestCase: r"""Updates the specified test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = client.update_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateTestCaseRequest, dict]): The request object. The request message for @@ -859,7 +1001,7 @@ def update_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([test_case, update_mask]) if request is not None and has_flattened_params: @@ -919,6 +1061,30 @@ def run_test_case( - ``response``: [RunTestCaseResponse][google.cloud.dialogflow.cx.v3.RunTestCaseResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.RunTestCaseRequest, dict]): The request object. The request message for @@ -991,6 +1157,31 @@ def batch_run_test_cases( - ``response``: [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3.BatchRunTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.BatchRunTestCasesRequest, dict]): The request object. The request message for @@ -1053,6 +1244,26 @@ def calculate_coverage( ) -> test_case.CalculateCoverageResponse: r"""Calculates the test coverage for an agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = client.calculate_coverage(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CalculateCoverageRequest, dict]): The request object. The request message for @@ -1116,6 +1327,31 @@ def import_test_cases( - ``response``: [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3.ImportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ImportTestCasesRequest, dict]): The request object. The request message for @@ -1190,6 +1426,31 @@ def export_test_cases( - ``response``: [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3.ExportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ExportTestCasesRequest, dict]): The request object. The request message for @@ -1253,6 +1514,26 @@ def list_test_case_results( ) -> pagers.ListTestCaseResultsPager: r"""Fetches a list of results for a given test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListTestCaseResultsRequest, dict]): The request object. The request message for @@ -1282,7 +1563,7 @@ def list_test_case_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1335,6 +1616,25 @@ def get_test_case_result( ) -> test_case.TestCaseResult: r"""Gets a test case result. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetTestCaseResultRequest, dict]): The request object. The request message for @@ -1359,7 +1659,7 @@ def get_test_case_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py b/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py index b8ce5606..b48cf255 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py index caa2815b..10d2c977 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 ce47fb7f..053445b2 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 fce3ccf6..01528be7 100644 --- a/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/test_cases/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -165,8 +165,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 66688c57..f9140728 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -210,8 +210,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -241,7 +244,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py index c5098c8b..629c785e 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 b9d26a87..0a3bea91 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -127,6 +127,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return TransitionRouteGroupsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> TransitionRouteGroupsTransport: """Returns the transport used by the client instance. @@ -202,6 +238,27 @@ async def list_transition_route_groups( r"""Returns the list of all transition route groups in the specified flow. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsRequest, dict]): The request object. The request message for @@ -230,7 +287,7 @@ async def list_transition_route_groups( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -286,6 +343,26 @@ async def get_transition_route_group( r"""Retrieves the specified [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -314,7 +391,7 @@ async def get_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -370,6 +447,30 @@ async def create_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.create_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -405,7 +506,7 @@ async def create_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, transition_route_group]) if request is not None and has_flattened_params: @@ -462,6 +563,29 @@ async def update_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.update_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -495,7 +619,7 @@ async def update_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([transition_route_group, update_mask]) if request is not None and has_flattened_params: @@ -553,6 +677,23 @@ async def delete_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_transition_route_group(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -573,7 +714,7 @@ async def delete_transition_route_group( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: 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 6d40da96..0c8b2a5d 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -315,6 +315,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -365,57 +432,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, TransitionRouteGroupsTransport): # transport is a TransitionRouteGroupsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -427,6 +459,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -453,6 +494,27 @@ def list_transition_route_groups( r"""Returns the list of all transition route groups in the specified flow. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListTransitionRouteGroupsRequest, dict]): The request object. The request message for @@ -481,7 +543,7 @@ def list_transition_route_groups( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -541,6 +603,26 @@ def get_transition_route_group( r"""Retrieves the specified [TransitionRouteGroup][google.cloud.dialogflow.cx.v3.TransitionRouteGroup]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -569,7 +651,7 @@ def get_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -629,6 +711,30 @@ def create_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.create_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -664,7 +770,7 @@ def create_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, transition_route_group]) if request is not None and has_flattened_params: @@ -727,6 +833,29 @@ def update_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.update_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -760,7 +889,7 @@ def update_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([transition_route_group, update_mask]) if request is not None and has_flattened_params: @@ -824,6 +953,23 @@ def delete_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_transition_route_group(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -844,7 +990,7 @@ def delete_transition_route_group( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py index bcfad7e7..739b9c81 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py index 1f1275f6..ed445782 100644 --- a/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/transition_route_groups/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 39ae3843..34194e1f 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 109b9a36..8e257254 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 08dbc516..d8935421 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/services/versions/__init__.py b/google/cloud/dialogflowcx_v3/services/versions/__init__.py index 586be181..78f73aa3 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/versions/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/versions/async_client.py b/google/cloud/dialogflowcx_v3/services/versions/async_client.py index 2a683fc1..d18cbb02 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/versions/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -108,6 +108,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return VersionsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> VersionsTransport: """Returns the transport used by the client instance. @@ -180,6 +216,27 @@ async def list_versions( r"""Returns the list of all versions in the specified [Flow][google.cloud.dialogflow.cx.v3.Flow]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_versions(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListVersionsRequest, dict]): The request object. The request message for @@ -208,7 +265,7 @@ async def list_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -262,6 +319,26 @@ async def get_version( r"""Retrieves the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetVersionRequest, dict]): The request object. The request message for @@ -286,7 +363,7 @@ async def get_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -345,6 +422,34 @@ async def create_version( - ``response``: [Version][google.cloud.dialogflow.cx.v3.Version] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateVersionRequest, dict]): The request object. The request message for @@ -380,7 +485,7 @@ async def create_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, version]) if request is not None and has_flattened_params: @@ -439,6 +544,29 @@ async def update_version( r"""Updates the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateVersionRequest, dict]): The request object. The request message for @@ -467,7 +595,7 @@ async def update_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([version, update_mask]) if request is not None and has_flattened_params: @@ -519,6 +647,23 @@ async def delete_version( r"""Deletes the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + client.delete_version(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteVersionRequest, dict]): The request object. The request message for @@ -539,7 +684,7 @@ async def delete_version( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -595,6 +740,30 @@ async def load_version( - ``response``: An `Empty message `__ + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_load_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.LoadVersionRequest, dict]): The request object. The request message for @@ -634,7 +803,7 @@ async def load_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -690,6 +859,27 @@ async def compare_versions( r"""Compares the specified base version with target version. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = client.compare_versions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CompareVersionsRequest, dict]): The request object. The request message for @@ -718,7 +908,7 @@ async def compare_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([base_version]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/versions/client.py b/google/cloud/dialogflowcx_v3/services/versions/client.py index e5b522bb..fca7c7f2 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/client.py +++ b/google/cloud/dialogflowcx_v3/services/versions/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -244,6 +244,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -294,57 +361,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, VersionsTransport): # transport is a VersionsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -356,6 +388,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -380,6 +421,27 @@ def list_versions( r"""Returns the list of all versions in the specified [Flow][google.cloud.dialogflow.cx.v3.Flow]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_versions(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListVersionsRequest, dict]): The request object. The request message for @@ -408,7 +470,7 @@ def list_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -462,6 +524,26 @@ def get_version( r"""Retrieves the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetVersionRequest, dict]): The request object. The request message for @@ -486,7 +568,7 @@ def get_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -545,6 +627,34 @@ def create_version( - ``response``: [Version][google.cloud.dialogflow.cx.v3.Version] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateVersionRequest, dict]): The request object. The request message for @@ -580,7 +690,7 @@ def create_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, version]) if request is not None and has_flattened_params: @@ -639,6 +749,29 @@ def update_version( r"""Updates the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateVersionRequest, dict]): The request object. The request message for @@ -667,7 +800,7 @@ def update_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([version, update_mask]) if request is not None and has_flattened_params: @@ -719,6 +852,23 @@ def delete_version( r"""Deletes the specified [Version][google.cloud.dialogflow.cx.v3.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + client.delete_version(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteVersionRequest, dict]): The request object. The request message for @@ -739,7 +889,7 @@ def delete_version( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -795,6 +945,30 @@ def load_version( - ``response``: An `Empty message `__ + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_load_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.LoadVersionRequest, dict]): The request object. The request message for @@ -834,7 +1008,7 @@ def load_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -890,6 +1064,27 @@ def compare_versions( r"""Compares the specified base version with target version. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = client.compare_versions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CompareVersionsRequest, dict]): The request object. The request message for @@ -918,7 +1113,7 @@ def compare_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([base_version]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/versions/pagers.py b/google/cloud/dialogflowcx_v3/services/versions/pagers.py index 09e3f31e..f67dc5ab 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/versions/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py index c5a42a0e..ab80b3b5 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/versions/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/versions/transports/base.py b/google/cloud/dialogflowcx_v3/services/versions/transports/base.py index 4a3f74cf..8fd450c4 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/versions/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py index d8ef3124..4b331d7f 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 5911b827..c2a45a81 100644 --- a/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/versions/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py b/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py index 28308a0b..7830ed1f 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py b/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py index 3e40edeb..3f4fc97b 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -105,6 +105,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return WebhooksClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> WebhooksTransport: """Returns the transport used by the client instance. @@ -177,6 +213,27 @@ async def list_webhooks( r"""Returns the list of all webhooks in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListWebhooksRequest, dict]): The request object. The request message for @@ -204,7 +261,7 @@ async def list_webhooks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -257,6 +314,25 @@ async def get_webhook( ) -> webhook.Webhook: r"""Retrieves the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = client.get_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetWebhookRequest, dict]): The request object. The request message for @@ -286,7 +362,7 @@ async def get_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -334,6 +410,30 @@ async def create_webhook( ) -> gcdc_webhook.Webhook: r"""Creates a webhook in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = client.create_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateWebhookRequest, dict]): The request object. The request message for @@ -368,7 +468,7 @@ async def create_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, webhook]) if request is not None and has_flattened_params: @@ -418,6 +518,29 @@ async def update_webhook( ) -> gcdc_webhook.Webhook: r"""Updates the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = client.update_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateWebhookRequest, dict]): The request object. The request message for @@ -453,7 +576,7 @@ async def update_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([webhook, update_mask]) if request is not None and has_flattened_params: @@ -504,6 +627,22 @@ async def delete_webhook( ) -> None: r"""Deletes the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + client.delete_webhook(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteWebhookRequest, dict]): The request object. The request message for @@ -522,7 +661,7 @@ async def delete_webhook( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/client.py b/google/cloud/dialogflowcx_v3/services/webhooks/client.py index bf69ccd9..4538b75d 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/client.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -253,6 +253,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -303,57 +370,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, WebhooksTransport): # transport is a WebhooksTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -365,6 +397,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -389,6 +430,27 @@ def list_webhooks( r"""Returns the list of all webhooks in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.ListWebhooksRequest, dict]): The request object. The request message for @@ -416,7 +478,7 @@ def list_webhooks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -469,6 +531,25 @@ def get_webhook( ) -> webhook.Webhook: r"""Retrieves the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = client.get_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.GetWebhookRequest, dict]): The request object. The request message for @@ -498,7 +579,7 @@ def get_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -546,6 +627,30 @@ def create_webhook( ) -> gcdc_webhook.Webhook: r"""Creates a webhook in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = client.create_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.CreateWebhookRequest, dict]): The request object. The request message for @@ -580,7 +685,7 @@ def create_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, webhook]) if request is not None and has_flattened_params: @@ -630,6 +735,29 @@ def update_webhook( ) -> gcdc_webhook.Webhook: r"""Updates the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = client.update_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3.types.UpdateWebhookRequest, dict]): The request object. The request message for @@ -665,7 +793,7 @@ def update_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([webhook, update_mask]) if request is not None and has_flattened_params: @@ -716,6 +844,22 @@ def delete_webhook( ) -> None: r"""Deletes the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3 + + def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + client.delete_webhook(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3.types.DeleteWebhookRequest, dict]): The request object. The request message for @@ -734,7 +878,7 @@ def delete_webhook( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py b/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py index a8151f0f..c5b792e1 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py b/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py index 17f318f9..2beebd10 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py b/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py index 0bdababd..85b7f7a6 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py index ab45da6c..cec5b3e0 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 0d177ec8..e3ce5b95 100644 --- a/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3/services/webhooks/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3/types/__init__.py b/google/cloud/dialogflowcx_v3/types/__init__.py index 50d69e71..f5baa497 100644 --- a/google/cloud/dialogflowcx_v3/types/__init__.py +++ b/google/cloud/dialogflowcx_v3/types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/advanced_settings.py b/google/cloud/dialogflowcx_v3/types/advanced_settings.py index 33544604..c5f8ece2 100644 --- a/google/cloud/dialogflowcx_v3/types/advanced_settings.py +++ b/google/cloud/dialogflowcx_v3/types/advanced_settings.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/agent.py b/google/cloud/dialogflowcx_v3/types/agent.py index 3995b66b..0eb00d84 100644 --- a/google/cloud/dialogflowcx_v3/types/agent.py +++ b/google/cloud/dialogflowcx_v3/types/agent.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/audio_config.py b/google/cloud/dialogflowcx_v3/types/audio_config.py index 1f0a8ace..b80a0788 100644 --- a/google/cloud/dialogflowcx_v3/types/audio_config.py +++ b/google/cloud/dialogflowcx_v3/types/audio_config.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/changelog.py b/google/cloud/dialogflowcx_v3/types/changelog.py index a58f7390..cc7325bc 100644 --- a/google/cloud/dialogflowcx_v3/types/changelog.py +++ b/google/cloud/dialogflowcx_v3/types/changelog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/deployment.py b/google/cloud/dialogflowcx_v3/types/deployment.py index 6c325e16..61b38bdf 100644 --- a/google/cloud/dialogflowcx_v3/types/deployment.py +++ b/google/cloud/dialogflowcx_v3/types/deployment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/entity_type.py b/google/cloud/dialogflowcx_v3/types/entity_type.py index 5fd80265..ae91a7bf 100644 --- a/google/cloud/dialogflowcx_v3/types/entity_type.py +++ b/google/cloud/dialogflowcx_v3/types/entity_type.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/environment.py b/google/cloud/dialogflowcx_v3/types/environment.py index 11e8135a..014d2d7e 100644 --- a/google/cloud/dialogflowcx_v3/types/environment.py +++ b/google/cloud/dialogflowcx_v3/types/environment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -104,7 +104,7 @@ class TestCasesConfig(proto.Message): enable_continuous_run (bool): Whether to run test cases in [TestCasesConfig.test_cases][google.cloud.dialogflow.cx.v3.Environment.TestCasesConfig.test_cases] - periodically. Default false. If set to ture, run once a day. + periodically. Default false. If set to true, run once a day. enable_predeployment_run (bool): Whether to run test cases in [TestCasesConfig.test_cases][google.cloud.dialogflow.cx.v3.Environment.TestCasesConfig.test_cases] diff --git a/google/cloud/dialogflowcx_v3/types/experiment.py b/google/cloud/dialogflowcx_v3/types/experiment.py index 78f6f8bf..f720d59d 100644 --- a/google/cloud/dialogflowcx_v3/types/experiment.py +++ b/google/cloud/dialogflowcx_v3/types/experiment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/flow.py b/google/cloud/dialogflowcx_v3/types/flow.py index 1b570d98..ef0a8c87 100644 --- a/google/cloud/dialogflowcx_v3/types/flow.py +++ b/google/cloud/dialogflowcx_v3/types/flow.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/fulfillment.py b/google/cloud/dialogflowcx_v3/types/fulfillment.py index 6df925c9..7033027e 100644 --- a/google/cloud/dialogflowcx_v3/types/fulfillment.py +++ b/google/cloud/dialogflowcx_v3/types/fulfillment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/intent.py b/google/cloud/dialogflowcx_v3/types/intent.py index 855c0315..706e1dae 100644 --- a/google/cloud/dialogflowcx_v3/types/intent.py +++ b/google/cloud/dialogflowcx_v3/types/intent.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/page.py b/google/cloud/dialogflowcx_v3/types/page.py index 8dc879a7..fc5ec3fb 100644 --- a/google/cloud/dialogflowcx_v3/types/page.py +++ b/google/cloud/dialogflowcx_v3/types/page.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/response_message.py b/google/cloud/dialogflowcx_v3/types/response_message.py index 6dde9256..8b4da716 100644 --- a/google/cloud/dialogflowcx_v3/types/response_message.py +++ b/google/cloud/dialogflowcx_v3/types/response_message.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -107,8 +107,8 @@ class ResponseMessage(proto.Message): This field is a member of `oneof`_ ``message``. telephony_transfer_call (google.cloud.dialogflowcx_v3.types.ResponseMessage.TelephonyTransferCall): A signal that the client should transfer the - phone call connected to this agent to a third- - party endpoint. + phone call connected to this agent to a + third-party endpoint. This field is a member of `oneof`_ ``message``. """ diff --git a/google/cloud/dialogflowcx_v3/types/security_settings.py b/google/cloud/dialogflowcx_v3/types/security_settings.py index af2d374a..a0b50762 100644 --- a/google/cloud/dialogflowcx_v3/types/security_settings.py +++ b/google/cloud/dialogflowcx_v3/types/security_settings.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -255,7 +255,7 @@ class PurgeDataType(proto.Enum): class InsightsExportSettings(proto.Message): r"""Settings for exporting conversations to - `Insights `__. + `Insights `__. Attributes: enable_insights_export (bool): diff --git a/google/cloud/dialogflowcx_v3/types/session.py b/google/cloud/dialogflowcx_v3/types/session.py index e74083cf..8fc20051 100644 --- a/google/cloud/dialogflowcx_v3/types/session.py +++ b/google/cloud/dialogflowcx_v3/types/session.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -479,10 +479,11 @@ class QueryParameters(proto.Message): the headers configured through Dialogflow console if there is a conflict. Header names are case-insensitive. Google's specified headers are - not allowed. Including: "Host", "Content- - Length", "Connection", "From", "User-Agent", - "Accept-Encoding", "If-Modified-Since", "If- - None-Match", "X-Forwarded-For", etc. + not allowed. Including: "Host", + "Content-Length", "Connection", "From", + "User-Agent", "Accept-Encoding", + "If-Modified-Since", "If-None-Match", + "X-Forwarded-For", etc. flow_versions (Sequence[str]): A list of flow versions to override for the request. Format: ``projects//locations//agents//flows//versions/``. @@ -797,9 +798,12 @@ class Match(proto.Message): [``INTENT``][google.cloud.dialogflow.cx.v3.Match.MatchType] match type. event (str): - The event that matched the query. Only filled for - [``EVENT``][google.cloud.dialogflow.cx.v3.Match.MatchType] - match type. + The event that matched the query. Filled for + [``EVENT``][google.cloud.dialogflow.cx.v3.Match.MatchType], + [``NO_MATCH``][google.cloud.dialogflow.cx.v3.Match.MatchType] + and + [``NO_INPUT``][google.cloud.dialogflow.cx.v3.Match.MatchType] + match types. parameters (google.protobuf.struct_pb2.Struct): The collection of parameters extracted from the query. diff --git a/google/cloud/dialogflowcx_v3/types/session_entity_type.py b/google/cloud/dialogflowcx_v3/types/session_entity_type.py index c2b427c4..a06adb54 100644 --- a/google/cloud/dialogflowcx_v3/types/session_entity_type.py +++ b/google/cloud/dialogflowcx_v3/types/session_entity_type.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/test_case.py b/google/cloud/dialogflowcx_v3/types/test_case.py index d7e144e6..7f64db49 100644 --- a/google/cloud/dialogflowcx_v3/types/test_case.py +++ b/google/cloud/dialogflowcx_v3/types/test_case.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/transition_route_group.py b/google/cloud/dialogflowcx_v3/types/transition_route_group.py index ed10a1a0..7ba1230c 100644 --- a/google/cloud/dialogflowcx_v3/types/transition_route_group.py +++ b/google/cloud/dialogflowcx_v3/types/transition_route_group.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/validation_message.py b/google/cloud/dialogflowcx_v3/types/validation_message.py index fa255dce..588c5117 100644 --- a/google/cloud/dialogflowcx_v3/types/validation_message.py +++ b/google/cloud/dialogflowcx_v3/types/validation_message.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/version.py b/google/cloud/dialogflowcx_v3/types/version.py index 577fd012..7a81890a 100644 --- a/google/cloud/dialogflowcx_v3/types/version.py +++ b/google/cloud/dialogflowcx_v3/types/version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3/types/webhook.py b/google/cloud/dialogflowcx_v3/types/webhook.py index dbd06844..6405a98c 100644 --- a/google/cloud/dialogflowcx_v3/types/webhook.py +++ b/google/cloud/dialogflowcx_v3/types/webhook.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/__init__.py b/google/cloud/dialogflowcx_v3beta1/__init__.py index e2126f7a..ab54c15f 100644 --- a/google/cloud/dialogflowcx_v3beta1/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/__init__.py index 4de65971..e8e1c384 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/agents/__init__.py index 0501fa94..db2a1a7d 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py index faa44514..75d0eff0 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -124,6 +124,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return AgentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> AgentsTransport: """Returns the transport used by the client instance. @@ -196,6 +232,27 @@ async def list_agents( r"""Returns the list of all agents in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_agents(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListAgentsRequest, dict]): The request object. The request message for @@ -223,7 +280,7 @@ async def list_agents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -276,6 +333,25 @@ async def get_agent( ) -> agent.Agent: r"""Retrieves the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetAgentRequest, dict]): The request object. The request message for @@ -312,7 +388,7 @@ async def get_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -364,6 +440,32 @@ async def create_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = client.create_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateAgentRequest, dict]): The request object. The request message for @@ -405,7 +507,7 @@ async def create_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, agent]) if request is not None and has_flattened_params: @@ -459,6 +561,31 @@ async def update_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = client.update_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateAgentRequest, dict]): The request object. The request message for @@ -501,7 +628,7 @@ async def update_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([agent, update_mask]) if request is not None and has_flattened_params: @@ -552,6 +679,22 @@ async def delete_agent( ) -> None: r"""Deletes the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + client.delete_agent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteAgentRequest, dict]): The request object. The request message for @@ -570,7 +713,7 @@ async def delete_agent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -625,6 +768,30 @@ async def export_agent( - ``response``: [ExportAgentResponse][google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_export_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ExportAgentRequest, dict]): The request object. The request message for @@ -704,6 +871,31 @@ async def restore_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.RestoreAgentRequest, dict]): The request object. The request message for @@ -777,6 +969,26 @@ async def validate_agent( validated. Please call this API after the training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = client.validate_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ValidateAgentRequest, dict]): The request object. The request message for @@ -828,6 +1040,26 @@ async def get_agent_validation_result( r"""Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetAgentValidationResultRequest, dict]): The request object. The request message for @@ -852,7 +1084,7 @@ async def get_agent_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/client.py b/google/cloud/dialogflowcx_v3beta1/services/agents/client.py index de7872c1..82fd5c19 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -328,6 +328,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -378,57 +445,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, AgentsTransport): # transport is a AgentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -440,6 +472,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -464,6 +505,27 @@ def list_agents( r"""Returns the list of all agents in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_agents(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListAgentsRequest, dict]): The request object. The request message for @@ -491,7 +553,7 @@ def list_agents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -544,6 +606,25 @@ def get_agent( ) -> agent.Agent: r"""Retrieves the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetAgentRequest, dict]): The request object. The request message for @@ -580,7 +661,7 @@ def get_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -632,6 +713,32 @@ def create_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = client.create_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateAgentRequest, dict]): The request object. The request message for @@ -673,7 +780,7 @@ def create_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, agent]) if request is not None and has_flattened_params: @@ -727,6 +834,31 @@ def update_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = client.update_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateAgentRequest, dict]): The request object. The request message for @@ -769,7 +901,7 @@ def update_agent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([agent, update_mask]) if request is not None and has_flattened_params: @@ -820,6 +952,22 @@ def delete_agent( ) -> None: r"""Deletes the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + client.delete_agent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteAgentRequest, dict]): The request object. The request message for @@ -838,7 +986,7 @@ def delete_agent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -893,6 +1041,30 @@ def export_agent( - ``response``: [ExportAgentResponse][google.cloud.dialogflow.cx.v3beta1.ExportAgentResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_export_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ExportAgentRequest, dict]): The request object. The request message for @@ -973,6 +1145,31 @@ def restore_agent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.RestoreAgentRequest, dict]): The request object. The request message for @@ -1047,6 +1244,26 @@ def validate_agent( validated. Please call this API after the training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = client.validate_agent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ValidateAgentRequest, dict]): The request object. The request message for @@ -1099,6 +1316,26 @@ def get_agent_validation_result( r"""Gets the latest agent validation result. Agent validation is performed when ValidateAgent is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetAgentValidationResultRequest, dict]): The request object. The request message for @@ -1123,7 +1360,7 @@ def get_agent_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/agents/pagers.py index e63212d6..c2be8159 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/__init__.py index ceadcd3a..703a3046 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py index ac1bdb38..4d41a167 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py index 708b88fa..856a3a05 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 7dc79166..ff564f1c 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/agents/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/__init__.py index 028672a9..7ed8fe54 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/async_client.py index bcedd1fd..b0e1e72f 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -103,6 +103,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return ChangelogsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> ChangelogsTransport: """Returns the transport used by the client instance. @@ -174,6 +210,26 @@ async def list_changelogs( ) -> pagers.ListChangelogsAsyncPager: r"""Returns the list of Changelogs. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListChangelogsRequest, dict]): The request object. The request message for @@ -201,7 +257,7 @@ async def list_changelogs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -254,6 +310,25 @@ async def get_changelog( ) -> changelog.Changelog: r"""Retrieves the specified Changelog. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = client.get_changelog(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetChangelogRequest, dict]): The request object. The request message for @@ -278,7 +353,7 @@ async def get_changelog( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/client.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/client.py index 865a8299..15a598cd 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -235,6 +235,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -285,57 +352,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, ChangelogsTransport): # transport is a ChangelogsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -347,6 +379,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -370,6 +411,26 @@ def list_changelogs( ) -> pagers.ListChangelogsPager: r"""Returns the list of Changelogs. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListChangelogsRequest, dict]): The request object. The request message for @@ -397,7 +458,7 @@ def list_changelogs( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -450,6 +511,25 @@ def get_changelog( ) -> changelog.Changelog: r"""Retrieves the specified Changelog. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = client.get_changelog(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetChangelogRequest, dict]): The request object. The request message for @@ -474,7 +554,7 @@ def get_changelog( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/pagers.py index 98c43848..3770c5ff 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/__init__.py index 882554f3..34aa1f62 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/base.py index 1d5e554f..31c58485 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc.py index c3a0216d..59b41013 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -159,8 +159,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc_asyncio.py index b0d2e527..33463dd5 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/changelogs/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -204,8 +204,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/__init__.py index 59dd17bb..5a5d1148 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/async_client.py index c376175b..519ac94d 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -113,6 +113,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return DeploymentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> DeploymentsTransport: """Returns the transport used by the client instance. @@ -185,6 +221,27 @@ async def list_deployments( r"""Returns the list of all deployments in the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListDeploymentsRequest, dict]): The request object. The request message for @@ -214,7 +271,7 @@ async def list_deployments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -268,6 +325,26 @@ async def get_deployment( r"""Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3beta1.Deployment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetDeploymentRequest, dict]): The request object. The request message for @@ -299,7 +376,7 @@ async def get_deployment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/client.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/client.py index 0dd616e1..3ebc7fde 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -303,6 +303,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -353,57 +420,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, DeploymentsTransport): # transport is a DeploymentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -415,6 +447,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -439,6 +480,27 @@ def list_deployments( r"""Returns the list of all deployments in the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListDeploymentsRequest, dict]): The request object. The request message for @@ -468,7 +530,7 @@ def list_deployments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -522,6 +584,26 @@ def get_deployment( r"""Retrieves the specified [Deployment][google.cloud.dialogflow.cx.v3beta1.Deployment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetDeploymentRequest, dict]): The request object. The request message for @@ -553,7 +635,7 @@ def get_deployment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/pagers.py index 7f6c69ff..9983f6cf 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/__init__.py index 78292dd3..f902c685 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/base.py index 2e2bea70..4e071a91 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc.py index 16ef9c18..d8fc9cef 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -159,8 +159,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc_asyncio.py b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc_asyncio.py index 2391da28..0130145a 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/deployments/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -204,8 +204,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/__init__.py index 77cd53e9..b0093027 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 7037a885..bf7eca9d 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -106,6 +106,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return EntityTypesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> EntityTypesTransport: """Returns the transport used by the client instance. @@ -178,6 +214,27 @@ async def list_entity_types( r"""Returns the list of all entity types in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListEntityTypesRequest, dict]): The request object. The request message for @@ -206,7 +263,7 @@ async def list_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -259,6 +316,25 @@ async def get_entity_type( ) -> entity_type.EntityType: r"""Retrieves the specified entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetEntityTypeRequest, dict]): The request object. The request message for @@ -315,7 +391,7 @@ async def get_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -363,6 +439,30 @@ async def create_entity_type( ) -> gcdc_entity_type.EntityType: r"""Creates an entity type in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = client.create_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateEntityTypeRequest, dict]): The request object. The request message for @@ -424,7 +524,7 @@ async def create_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, entity_type]) if request is not None and has_flattened_params: @@ -478,6 +578,30 @@ async def update_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = client.update_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateEntityTypeRequest, dict]): The request object. The request message for @@ -539,7 +663,7 @@ async def update_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([entity_type, update_mask]) if request is not None and has_flattened_params: @@ -594,6 +718,23 @@ async def delete_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteEntityTypeRequest, dict]): The request object. The request message for @@ -612,7 +753,7 @@ async def delete_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py index 134cd63b..dc3fc6b9 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -238,6 +238,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -288,57 +355,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, EntityTypesTransport): # transport is a EntityTypesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -350,6 +382,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -374,6 +415,27 @@ def list_entity_types( r"""Returns the list of all entity types in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListEntityTypesRequest, dict]): The request object. The request message for @@ -402,7 +464,7 @@ def list_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -455,6 +517,25 @@ def get_entity_type( ) -> entity_type.EntityType: r"""Retrieves the specified entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetEntityTypeRequest, dict]): The request object. The request message for @@ -511,7 +592,7 @@ def get_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -559,6 +640,30 @@ def create_entity_type( ) -> gcdc_entity_type.EntityType: r"""Creates an entity type in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = client.create_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateEntityTypeRequest, dict]): The request object. The request message for @@ -620,7 +725,7 @@ def create_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, entity_type]) if request is not None and has_flattened_params: @@ -674,6 +779,30 @@ def update_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = client.update_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateEntityTypeRequest, dict]): The request object. The request message for @@ -735,7 +864,7 @@ def update_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([entity_type, update_mask]) if request is not None and has_flattened_params: @@ -790,6 +919,23 @@ def delete_entity_type( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteEntityTypeRequest, dict]): The request object. The request message for @@ -808,7 +954,7 @@ def delete_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/pagers.py index a6386734..6da458e5 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/__init__.py index 07ea82e1..2a22d664 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 59a4f731..3222f088 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 1aefc49b..bfadbb6e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/entity_types/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 bea433ec..aacbcf4d 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/environments/__init__.py index 0c2be948..22833765 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/environments/async_client.py index 25a9c6cd..7c561990 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -124,6 +124,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return EnvironmentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> EnvironmentsTransport: """Returns the transport used by the client instance. @@ -196,6 +232,27 @@ async def list_environments( r"""Returns the list of all environments in the specified [Agent][google.cloud.dialogflow.cx.v3beta1.Agent]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_environments(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListEnvironmentsRequest, dict]): The request object. The request message for @@ -225,7 +282,7 @@ async def list_environments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -279,6 +336,26 @@ async def get_environment( r"""Retrieves the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = client.get_environment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetEnvironmentRequest, dict]): The request object. The request message for @@ -318,7 +395,7 @@ async def get_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -378,6 +455,35 @@ async def create_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateEnvironmentRequest, dict]): The request object. The request message for @@ -422,7 +528,7 @@ async def create_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, environment]) if request is not None and has_flattened_params: @@ -491,6 +597,34 @@ async def update_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateEnvironmentRequest, dict]): The request object. The request message for @@ -531,7 +665,7 @@ async def update_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([environment, update_mask]) if request is not None and has_flattened_params: @@ -591,6 +725,23 @@ async def delete_environment( r"""Deletes the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + client.delete_environment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteEnvironmentRequest, dict]): The request object. The request message for @@ -611,7 +762,7 @@ async def delete_environment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -658,6 +809,27 @@ async def lookup_environment_history( r"""Looks up the history of the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.LookupEnvironmentHistoryRequest, dict]): The request object. The request message for @@ -686,7 +858,7 @@ async def lookup_environment_history( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -749,6 +921,30 @@ async def run_continuous_test( - ``response``: [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3beta1.RunContinuousTestResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.RunContinuousTestRequest, dict]): The request object. The request message for @@ -814,6 +1010,27 @@ async def list_continuous_test_results( r"""Fetches a list of continuous test results for a given environment. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListContinuousTestResultsRequest, dict]): The request object. The request message for @@ -841,7 +1058,7 @@ async def list_continuous_test_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -904,6 +1121,31 @@ async def deploy_flow( - ``response``: [DeployFlowResponse][google.cloud.dialogflow.cx.v3beta1.DeployFlowResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeployFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/client.py b/google/cloud/dialogflowcx_v3beta1/services/environments/client.py index 1a7017e1..5cda85d1 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -324,6 +324,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -374,57 +441,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, EnvironmentsTransport): # transport is a EnvironmentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -436,6 +468,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -460,6 +501,27 @@ def list_environments( r"""Returns the list of all environments in the specified [Agent][google.cloud.dialogflow.cx.v3beta1.Agent]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_environments(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListEnvironmentsRequest, dict]): The request object. The request message for @@ -489,7 +551,7 @@ def list_environments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -543,6 +605,26 @@ def get_environment( r"""Retrieves the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = client.get_environment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetEnvironmentRequest, dict]): The request object. The request message for @@ -582,7 +664,7 @@ def get_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -642,6 +724,35 @@ def create_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateEnvironmentRequest, dict]): The request object. The request message for @@ -686,7 +797,7 @@ def create_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, environment]) if request is not None and has_flattened_params: @@ -755,6 +866,34 @@ def update_environment( - ``response``: [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateEnvironmentRequest, dict]): The request object. The request message for @@ -795,7 +934,7 @@ def update_environment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([environment, update_mask]) if request is not None and has_flattened_params: @@ -855,6 +994,23 @@ def delete_environment( r"""Deletes the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + client.delete_environment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteEnvironmentRequest, dict]): The request object. The request message for @@ -875,7 +1031,7 @@ def delete_environment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -922,6 +1078,27 @@ def lookup_environment_history( r"""Looks up the history of the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.LookupEnvironmentHistoryRequest, dict]): The request object. The request message for @@ -950,7 +1127,7 @@ def lookup_environment_history( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1015,6 +1192,30 @@ def run_continuous_test( - ``response``: [RunContinuousTestResponse][google.cloud.dialogflow.cx.v3beta1.RunContinuousTestResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.RunContinuousTestRequest, dict]): The request object. The request message for @@ -1081,6 +1282,27 @@ def list_continuous_test_results( r"""Fetches a list of continuous test results for a given environment. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListContinuousTestResultsRequest, dict]): The request object. The request message for @@ -1108,7 +1330,7 @@ def list_continuous_test_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1173,6 +1395,31 @@ def deploy_flow( - ``response``: [DeployFlowResponse][google.cloud.dialogflow.cx.v3beta1.DeployFlowResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeployFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/environments/pagers.py index a4b0fbfb..19fb61d0 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/__init__.py index c72efee4..0ecefb61 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py index 299075a2..2fd2371d 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py index 864ff025..f0f46a74 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 493d3ed4..25a4d238 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/environments/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/__init__.py index 560b13da..550aae89 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/async_client.py index 28bf737c..e34c1a83 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -110,6 +110,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return ExperimentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> ExperimentsTransport: """Returns the transport used by the client instance. @@ -182,6 +218,27 @@ async def list_experiments( r"""Returns the list of all experiments in the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListExperimentsRequest, dict]): The request object. The request message for @@ -211,7 +268,7 @@ async def list_experiments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -265,6 +322,26 @@ async def get_experiment( r"""Retrieves the specified [Experiment][google.cloud.dialogflow.cx.v3beta1.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.get_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetExperimentRequest, dict]): The request object. The request message for @@ -291,7 +368,7 @@ async def get_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -342,6 +419,30 @@ async def create_experiment( the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = client.create_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateExperimentRequest, dict]): The request object. The request message for @@ -375,7 +476,7 @@ async def create_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, experiment]) if request is not None and has_flattened_params: @@ -426,6 +527,29 @@ async def update_experiment( r"""Updates the specified [Experiment][google.cloud.dialogflow.cx.v3beta1.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = client.update_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateExperimentRequest, dict]): The request object. The request message for @@ -455,7 +579,7 @@ async def update_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([experiment, update_mask]) if request is not None and has_flattened_params: @@ -507,6 +631,23 @@ async def delete_experiment( r"""Deletes the specified [Experiment][google.cloud.dialogflow.cx.v3beta1.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + client.delete_experiment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteExperimentRequest, dict]): The request object. The request message for @@ -527,7 +668,7 @@ async def delete_experiment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -576,6 +717,26 @@ async def start_experiment( This rpc only changes the state of experiment from PENDING to RUNNING. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.start_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.StartExperimentRequest, dict]): The request object. The request message for @@ -601,7 +762,7 @@ async def start_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -651,6 +812,26 @@ async def stop_experiment( This rpc only changes the state of experiment from RUNNING to DONE. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.stop_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.StopExperimentRequest, dict]): The request object. The request message for @@ -676,7 +857,7 @@ async def stop_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/client.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/client.py index 24771998..6cccc6b8 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -262,6 +262,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -312,57 +379,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, ExperimentsTransport): # transport is a ExperimentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -374,6 +406,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -398,6 +439,27 @@ def list_experiments( r"""Returns the list of all experiments in the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListExperimentsRequest, dict]): The request object. The request message for @@ -427,7 +489,7 @@ def list_experiments( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -481,6 +543,26 @@ def get_experiment( r"""Retrieves the specified [Experiment][google.cloud.dialogflow.cx.v3beta1.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.get_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetExperimentRequest, dict]): The request object. The request message for @@ -507,7 +589,7 @@ def get_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -558,6 +640,30 @@ def create_experiment( the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = client.create_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateExperimentRequest, dict]): The request object. The request message for @@ -591,7 +697,7 @@ def create_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, experiment]) if request is not None and has_flattened_params: @@ -642,6 +748,29 @@ def update_experiment( r"""Updates the specified [Experiment][google.cloud.dialogflow.cx.v3beta1.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = client.update_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateExperimentRequest, dict]): The request object. The request message for @@ -671,7 +800,7 @@ def update_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([experiment, update_mask]) if request is not None and has_flattened_params: @@ -723,6 +852,23 @@ def delete_experiment( r"""Deletes the specified [Experiment][google.cloud.dialogflow.cx.v3beta1.Experiment]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + client.delete_experiment(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteExperimentRequest, dict]): The request object. The request message for @@ -743,7 +889,7 @@ def delete_experiment( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -792,6 +938,26 @@ def start_experiment( This rpc only changes the state of experiment from PENDING to RUNNING. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.start_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.StartExperimentRequest, dict]): The request object. The request message for @@ -817,7 +983,7 @@ def start_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -867,6 +1033,26 @@ def stop_experiment( This rpc only changes the state of experiment from RUNNING to DONE. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.stop_experiment(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.StopExperimentRequest, dict]): The request object. The request message for @@ -892,7 +1078,7 @@ def stop_experiment( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/pagers.py index 53117dcf..fd6db5a4 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/__init__.py index 3be44737..3a6183c3 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py index 0829dad5..971a8c85 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py index 18ab0a79..e4745477 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 8336d648..0e339349 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/experiments/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/flows/__init__.py index 03ec82a2..184d3531 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py index 21d8a885..8631b3ab 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -121,6 +121,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return FlowsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> FlowsTransport: """Returns the transport used by the client instance. @@ -197,6 +233,30 @@ async def create_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = client.create_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateFlowRequest, dict]): The request object. The request message for @@ -247,7 +307,7 @@ async def create_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, flow]) if request is not None and has_flattened_params: @@ -296,6 +356,22 @@ async def delete_flow( ) -> None: r"""Deletes a specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + client.delete_flow(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteFlowRequest, dict]): The request object. The request message for @@ -314,7 +390,7 @@ async def delete_flow( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -360,6 +436,26 @@ async def list_flows( ) -> pagers.ListFlowsAsyncPager: r"""Returns the list of all flows in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_flows(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListFlowsRequest, dict]): The request object. The request message for @@ -387,7 +483,7 @@ async def list_flows( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -440,6 +536,25 @@ async def get_flow( ) -> flow.Flow: r"""Retrieves the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetFlowRequest, dict]): The request object. The response message for @@ -485,7 +600,7 @@ async def get_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -537,6 +652,29 @@ async def update_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = client.update_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateFlowRequest, dict]): The request object. The request message for @@ -588,7 +726,7 @@ async def update_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([flow, update_mask]) if request is not None and has_flattened_params: @@ -654,6 +792,30 @@ async def train_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_train_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.TrainFlowRequest, dict]): The request object. The request message for @@ -691,7 +853,7 @@ async def train_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -748,6 +910,26 @@ async def validate_flow( training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = client.validate_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ValidateFlowRequest, dict]): The request object. The request message for @@ -799,6 +981,26 @@ async def get_flow_validation_result( r"""Gets the latest flow validation result. Flow validation is performed when ValidateFlow is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetFlowValidationResultRequest, dict]): The request object. The request message for @@ -823,7 +1025,7 @@ async def get_flow_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -884,6 +1086,31 @@ async def import_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_import_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ImportFlowRequest, dict]): The request object. The request message for @@ -958,6 +1185,30 @@ async def export_flow( Note that resources (e.g. intents, entities, webhooks) that the flow references will also be exported. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_export_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ExportFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/client.py b/google/cloud/dialogflowcx_v3beta1/services/flows/client.py index 7cda4c8b..11351155 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -333,6 +333,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -383,57 +450,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, FlowsTransport): # transport is a FlowsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -445,6 +477,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -473,6 +514,30 @@ def create_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = client.create_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateFlowRequest, dict]): The request object. The request message for @@ -523,7 +588,7 @@ def create_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, flow]) if request is not None and has_flattened_params: @@ -572,6 +637,22 @@ def delete_flow( ) -> None: r"""Deletes a specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + client.delete_flow(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteFlowRequest, dict]): The request object. The request message for @@ -590,7 +671,7 @@ def delete_flow( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -636,6 +717,26 @@ def list_flows( ) -> pagers.ListFlowsPager: r"""Returns the list of all flows in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_flows(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListFlowsRequest, dict]): The request object. The request message for @@ -663,7 +764,7 @@ def list_flows( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -716,6 +817,25 @@ def get_flow( ) -> flow.Flow: r"""Retrieves the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetFlowRequest, dict]): The request object. The response message for @@ -761,7 +881,7 @@ def get_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -813,6 +933,29 @@ def update_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = client.update_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateFlowRequest, dict]): The request object. The request message for @@ -864,7 +1007,7 @@ def update_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([flow, update_mask]) if request is not None and has_flattened_params: @@ -930,6 +1073,30 @@ def train_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_train_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.TrainFlowRequest, dict]): The request object. The request message for @@ -967,7 +1134,7 @@ def train_flow( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1024,6 +1191,26 @@ def validate_flow( training is completed to get the complete validation results. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = client.validate_flow(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ValidateFlowRequest, dict]): The request object. The request message for @@ -1076,6 +1263,26 @@ def get_flow_validation_result( r"""Gets the latest flow validation result. Flow validation is performed when ValidateFlow is called. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetFlowValidationResultRequest, dict]): The request object. The request message for @@ -1100,7 +1307,7 @@ def get_flow_validation_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1163,6 +1370,31 @@ def import_flow( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_import_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ImportFlowRequest, dict]): The request object. The request message for @@ -1238,6 +1470,30 @@ def export_flow( Note that resources (e.g. intents, entities, webhooks) that the flow references will also be exported. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_export_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ExportFlowRequest, dict]): The request object. The request message for diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/flows/pagers.py index ddf29538..a56ab05c 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/__init__.py index f2970e47..d27c76de 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py index 3ac3b61f..3056b278 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py index e9d68422..45f775f3 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 f65b849e..3b275006 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/flows/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/intents/__init__.py index 5a2c263c..283553c4 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py index c940d14d..32b6fb5c 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -104,6 +104,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return IntentsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> IntentsTransport: """Returns the transport used by the client instance. @@ -176,6 +212,27 @@ async def list_intents( r"""Returns the list of all intents in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_intents(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListIntentsRequest, dict]): The request object. The request message for @@ -203,7 +260,7 @@ async def list_intents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -256,6 +313,25 @@ async def get_intent( ) -> intent.Intent: r"""Retrieves the specified intent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = client.get_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetIntentRequest, dict]): The request object. The request message for @@ -285,7 +361,7 @@ async def get_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -337,6 +413,30 @@ async def create_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = client.create_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateIntentRequest, dict]): The request object. The request message for @@ -371,7 +471,7 @@ async def create_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, intent]) if request is not None and has_flattened_params: @@ -425,6 +525,29 @@ async def update_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = client.update_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateIntentRequest, dict]): The request object. The request message for @@ -460,7 +583,7 @@ async def update_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([intent, update_mask]) if request is not None and has_flattened_params: @@ -515,6 +638,23 @@ async def delete_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + client.delete_intent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteIntentRequest, dict]): The request object. The request message for @@ -533,7 +673,7 @@ async def delete_intent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/client.py b/google/cloud/dialogflowcx_v3beta1/services/intents/client.py index ef095213..82092f1f 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -254,6 +254,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -304,57 +371,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, IntentsTransport): # transport is a IntentsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -366,6 +398,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -390,6 +431,27 @@ def list_intents( r"""Returns the list of all intents in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_intents(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListIntentsRequest, dict]): The request object. The request message for @@ -417,7 +479,7 @@ def list_intents( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -470,6 +532,25 @@ def get_intent( ) -> intent.Intent: r"""Retrieves the specified intent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = client.get_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetIntentRequest, dict]): The request object. The request message for @@ -499,7 +580,7 @@ def get_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -551,6 +632,30 @@ def create_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = client.create_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateIntentRequest, dict]): The request object. The request message for @@ -585,7 +690,7 @@ def create_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, intent]) if request is not None and has_flattened_params: @@ -639,6 +744,29 @@ def update_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = client.update_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateIntentRequest, dict]): The request object. The request message for @@ -674,7 +802,7 @@ def update_intent( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([intent, update_mask]) if request is not None and has_flattened_params: @@ -729,6 +857,23 @@ def delete_intent( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + client.delete_intent(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteIntentRequest, dict]): The request object. The request message for @@ -747,7 +892,7 @@ def delete_intent( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/intents/pagers.py index 8cd5a636..e57d5895 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/__init__.py index 974a5810..876b5cd1 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py index ed4bc388..e3d8d90a 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py index c5a796b9..4820a66e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 3335f773..688be213 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/intents/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/pages/__init__.py index c5a52656..5a89d061 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/pages/async_client.py index 1b8a0b56..e23420c5 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -113,6 +113,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return PagesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> PagesTransport: """Returns the transport used by the client instance. @@ -184,6 +220,26 @@ async def list_pages( ) -> pagers.ListPagesAsyncPager: r"""Returns the list of all pages in the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_pages(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListPagesRequest, dict]): The request object. The request message for @@ -211,7 +267,7 @@ async def list_pages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -264,6 +320,25 @@ async def get_page( ) -> page.Page: r"""Retrieves the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetPageRequest( + name="name_value", + ) + + # Make the request + response = client.get_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetPageRequest, dict]): The request object. The request message for @@ -308,7 +383,7 @@ async def get_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -356,6 +431,29 @@ async def create_page( ) -> gcdc_page.Page: r"""Creates a page in the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = client.create_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreatePageRequest, dict]): The request object. The request message for @@ -405,7 +503,7 @@ async def create_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, page]) if request is not None and has_flattened_params: @@ -455,6 +553,28 @@ async def update_page( ) -> gcdc_page.Page: r"""Updates the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdatePageRequest( + page=page, + ) + + # Make the request + response = client.update_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdatePageRequest, dict]): The request object. The request message for @@ -505,7 +625,7 @@ async def update_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([page, update_mask]) if request is not None and has_flattened_params: @@ -556,6 +676,22 @@ async def delete_page( ) -> None: r"""Deletes the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeletePageRequest( + name="name_value", + ) + + # Make the request + client.delete_page(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeletePageRequest, dict]): The request object. The request message for @@ -574,7 +710,7 @@ async def delete_page( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/client.py b/google/cloud/dialogflowcx_v3beta1/services/pages/client.py index 9f715945..4992a8a1 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -327,6 +327,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -377,57 +444,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, PagesTransport): # transport is a PagesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -439,6 +471,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -462,6 +503,26 @@ def list_pages( ) -> pagers.ListPagesPager: r"""Returns the list of all pages in the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_pages(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListPagesRequest, dict]): The request object. The request message for @@ -489,7 +550,7 @@ def list_pages( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -542,6 +603,25 @@ def get_page( ) -> page.Page: r"""Retrieves the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetPageRequest( + name="name_value", + ) + + # Make the request + response = client.get_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetPageRequest, dict]): The request object. The request message for @@ -586,7 +666,7 @@ def get_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -634,6 +714,29 @@ def create_page( ) -> gcdc_page.Page: r"""Creates a page in the specified flow. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = client.create_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreatePageRequest, dict]): The request object. The request message for @@ -683,7 +786,7 @@ def create_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, page]) if request is not None and has_flattened_params: @@ -733,6 +836,28 @@ def update_page( ) -> gcdc_page.Page: r"""Updates the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdatePageRequest( + page=page, + ) + + # Make the request + response = client.update_page(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdatePageRequest, dict]): The request object. The request message for @@ -783,7 +908,7 @@ def update_page( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([page, update_mask]) if request is not None and has_flattened_params: @@ -834,6 +959,22 @@ def delete_page( ) -> None: r"""Deletes the specified page. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeletePageRequest( + name="name_value", + ) + + # Make the request + client.delete_page(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeletePageRequest, dict]): The request object. The request message for @@ -852,7 +993,7 @@ def delete_page( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/pages/pagers.py index b7ffcf10..013f6cc3 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/__init__.py index fff7089d..fd23f06e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py index ef38536e..fdb0d617 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py index 7b8165aa..b17e9122 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 4b78d2ff..29169f8b 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/pages/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/__init__.py index d8b471f4..8d770740 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/async_client.py index 2353cfd5..02913f88 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -130,6 +130,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SecuritySettingsServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SecuritySettingsServiceTransport: """Returns the transport used by the client instance. @@ -205,6 +241,30 @@ async def create_security_settings( ) -> gcdc_security_settings.SecuritySettings: r"""Create security settings in the specified location. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = client.create_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateSecuritySettingsRequest, dict]): The request object. The request message for @@ -242,7 +302,7 @@ async def create_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, security_settings]) if request is not None and has_flattened_params: @@ -293,6 +353,26 @@ async def get_security_settings( [SecuritySettings][google.cloud.dialogflow.cx.v3beta1.SecuritySettings]. The returned settings may be stale by up to 1 minute. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetSecuritySettingsRequest, dict]): The request object. The request message for @@ -321,7 +401,7 @@ async def get_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -372,6 +452,30 @@ async def update_security_settings( r"""Updates the specified [SecuritySettings][google.cloud.dialogflow.cx.v3beta1.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = client.update_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateSecuritySettingsRequest, dict]): The request object. The request message for @@ -408,7 +512,7 @@ async def update_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([security_settings, update_mask]) if request is not None and has_flattened_params: @@ -460,6 +564,27 @@ async def list_security_settings( r"""Returns the list of all security settings in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListSecuritySettingsRequest, dict]): The request object. The request message for @@ -488,7 +613,7 @@ async def list_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -542,6 +667,23 @@ async def delete_security_settings( r"""Deletes the specified [SecuritySettings][google.cloud.dialogflow.cx.v3beta1.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + client.delete_security_settings(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteSecuritySettingsRequest, dict]): The request object. The request message for @@ -562,7 +704,7 @@ async def delete_security_settings( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/client.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/client.py index 4e003284..f63e9060 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -282,6 +282,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -332,57 +399,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SecuritySettingsServiceTransport): # transport is a SecuritySettingsServiceTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -394,6 +426,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -420,6 +461,30 @@ def create_security_settings( ) -> gcdc_security_settings.SecuritySettings: r"""Create security settings in the specified location. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = client.create_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateSecuritySettingsRequest, dict]): The request object. The request message for @@ -457,7 +522,7 @@ def create_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, security_settings]) if request is not None and has_flattened_params: @@ -510,6 +575,26 @@ def get_security_settings( [SecuritySettings][google.cloud.dialogflow.cx.v3beta1.SecuritySettings]. The returned settings may be stale by up to 1 minute. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetSecuritySettingsRequest, dict]): The request object. The request message for @@ -538,7 +623,7 @@ def get_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -589,6 +674,30 @@ def update_security_settings( r"""Updates the specified [SecuritySettings][google.cloud.dialogflow.cx.v3beta1.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = client.update_security_settings(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateSecuritySettingsRequest, dict]): The request object. The request message for @@ -625,7 +734,7 @@ def update_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([security_settings, update_mask]) if request is not None and has_flattened_params: @@ -679,6 +788,27 @@ def list_security_settings( r"""Returns the list of all security settings in the specified location. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListSecuritySettingsRequest, dict]): The request object. The request message for @@ -707,7 +837,7 @@ def list_security_settings( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -761,6 +891,23 @@ def delete_security_settings( r"""Deletes the specified [SecuritySettings][google.cloud.dialogflow.cx.v3beta1.SecuritySettings]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + client.delete_security_settings(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteSecuritySettingsRequest, dict]): The request object. The request message for @@ -781,7 +928,7 @@ def delete_security_settings( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/pagers.py index 5bf37c15..1b13841e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/__init__.py index 8f3a8c8b..bcf597b1 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/security_settings_service/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 e2cabf07..918f166b 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 3683029b..fe896ffd 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -162,8 +162,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 8b97875e..0eeea24a 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -207,8 +207,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/__init__.py index cbd406b4..a8d58e17 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/async_client.py index 0f2551d8..a692d9af 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -117,6 +117,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SessionEntityTypesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SessionEntityTypesTransport: """Returns the transport used by the client instance. @@ -190,6 +226,27 @@ async def list_session_entity_types( r"""Returns the list of all session entity types in the specified session. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListSessionEntityTypesRequest, dict]): The request object. The request message for @@ -222,7 +279,7 @@ async def list_session_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -275,6 +332,25 @@ async def get_session_entity_type( ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetSessionEntityTypeRequest, dict]): The request object. The request message for @@ -318,7 +394,7 @@ async def get_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -368,6 +444,32 @@ async def create_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Creates a session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.create_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -419,7 +521,7 @@ async def create_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, session_entity_type]) if request is not None and has_flattened_params: @@ -471,6 +573,31 @@ async def update_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.update_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -521,7 +648,7 @@ async def update_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([session_entity_type, update_mask]) if request is not None and has_flattened_params: @@ -572,6 +699,22 @@ async def delete_session_entity_type( ) -> None: r"""Deletes the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_session_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteSessionEntityTypeRequest, dict]): The request object. The request message for @@ -595,7 +738,7 @@ async def delete_session_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/client.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/client.py index 4176db12..d19c9d0e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -249,6 +249,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -299,57 +366,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SessionEntityTypesTransport): # transport is a SessionEntityTypesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -361,6 +393,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -385,6 +426,27 @@ def list_session_entity_types( r"""Returns the list of all session entity types in the specified session. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListSessionEntityTypesRequest, dict]): The request object. The request message for @@ -417,7 +479,7 @@ def list_session_entity_types( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -472,6 +534,25 @@ def get_session_entity_type( ) -> session_entity_type.SessionEntityType: r"""Retrieves the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetSessionEntityTypeRequest, dict]): The request object. The request message for @@ -515,7 +596,7 @@ def get_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -565,6 +646,32 @@ def create_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Creates a session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.create_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -616,7 +723,7 @@ def create_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, session_entity_type]) if request is not None and has_flattened_params: @@ -672,6 +779,31 @@ def update_session_entity_type( ) -> gcdc_session_entity_type.SessionEntityType: r"""Updates the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.update_session_entity_type(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateSessionEntityTypeRequest, dict]): The request object. The request message for @@ -722,7 +854,7 @@ def update_session_entity_type( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([session_entity_type, update_mask]) if request is not None and has_flattened_params: @@ -777,6 +909,22 @@ def delete_session_entity_type( ) -> None: r"""Deletes the specified session entity type. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_session_entity_type(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteSessionEntityTypeRequest, dict]): The request object. The request message for @@ -800,7 +948,7 @@ def delete_session_entity_type( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/pagers.py index 575be423..38a09b03 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/__init__.py index 633fd32c..44e2a8d4 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/session_entity_types/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 cdc00fc2..3d817be8 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 b65f46fa..ae607e60 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 70130469..c9c1c09d 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/__init__.py index 0adeafb9..49b86a28 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py index 64110de2..8fe223b3 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import re from typing import ( Dict, + Optional, AsyncIterable, Awaitable, AsyncIterator, @@ -134,6 +135,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SessionsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> SessionsTransport: """Returns the transport used by the client instance. @@ -211,6 +248,31 @@ async def detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.detect_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DetectIntentRequest, dict]): The request object. The request to detect user's intent. @@ -275,6 +337,41 @@ def streaming_detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3beta1.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + for response in stream: + print(response) + Args: requests (AsyncIterator[`google.cloud.dialogflowcx_v3beta1.types.StreamingDetectIntentRequest`]): The request object AsyncIterator. The top-level message sent by the @@ -379,6 +476,31 @@ async def match_intent( r"""Returns preliminary intent match results, doesn't change the session status. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_match_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.match_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.MatchIntentRequest, dict]): The request object. Request of [MatchIntent][]. @@ -431,6 +553,25 @@ async def fulfill_intent( [MatchIntentResponse][google.cloud.dialogflow.cx.v3beta1.MatchIntentResponse]. Otherwise, the behavior is undefined. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.FulfillIntentRequest( + ) + + # Make the request + response = client.fulfill_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.FulfillIntentRequest, dict]): The request object. Request of [FulfillIntent][] diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py index bf6e70db..0391eb7a 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -383,6 +383,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -433,57 +500,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, SessionsTransport): # transport is a SessionsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -495,6 +527,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -524,6 +565,31 @@ def detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.detect_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DetectIntentRequest, dict]): The request object. The request to detect user's intent. @@ -580,6 +646,41 @@ def streaming_detect_intent( `Versions and environments `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3beta1.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + for response in stream: + print(response) + Args: requests (Iterator[google.cloud.dialogflowcx_v3beta1.types.StreamingDetectIntentRequest]): The request object iterator. The top-level message sent by the @@ -680,6 +781,31 @@ def match_intent( r"""Returns preliminary intent match results, doesn't change the session status. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_match_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.match_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.MatchIntentRequest, dict]): The request object. Request of [MatchIntent][]. @@ -733,6 +859,25 @@ def fulfill_intent( [MatchIntentResponse][google.cloud.dialogflow.cx.v3beta1.MatchIntentResponse]. Otherwise, the behavior is undefined. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.FulfillIntentRequest( + ) + + # Make the request + response = client.fulfill_intent(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.FulfillIntentRequest, dict]): The request object. Request of [FulfillIntent][] diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/__init__.py index db0f7d04..ce00ff37 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py index 45bccb99..d3c2c3d1 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py index 69e1aea5..f2a3e39b 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 ec09246e..6db59ffe 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/sessions/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/__init__.py index 359c8900..f9c1fe81 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/async_client.py index 903b29ec..961d1d6d 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -132,6 +132,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return TestCasesClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> TestCasesTransport: """Returns the transport used by the client instance. @@ -203,6 +239,26 @@ async def list_test_cases( ) -> pagers.ListTestCasesAsyncPager: r"""Fetches a list of test cases for a given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListTestCasesRequest, dict]): The request object. The request message for @@ -230,7 +286,7 @@ async def list_test_cases( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -283,6 +339,23 @@ async def batch_delete_test_cases( ) -> None: r"""Batch deletes test cases. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + client.batch_delete_test_cases(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.BatchDeleteTestCasesRequest, dict]): The request object. The request message for @@ -301,7 +374,7 @@ async def batch_delete_test_cases( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -347,6 +420,25 @@ async def get_test_case( ) -> test_case.TestCase: r"""Gets a test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetTestCaseRequest, dict]): The request object. The request message for @@ -369,7 +461,7 @@ async def get_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -417,6 +509,29 @@ async def create_test_case( ) -> gcdc_test_case.TestCase: r"""Creates a test case for the given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = client.create_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateTestCaseRequest, dict]): The request object. The request message for @@ -444,7 +559,7 @@ async def create_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, test_case]) if request is not None and has_flattened_params: @@ -494,6 +609,28 @@ async def update_test_case( ) -> gcdc_test_case.TestCase: r"""Updates the specified test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = client.update_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateTestCaseRequest, dict]): The request object. The request message for @@ -525,7 +662,7 @@ async def update_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([test_case, update_mask]) if request is not None and has_flattened_params: @@ -585,6 +722,30 @@ async def run_test_case( - ``response``: [RunTestCaseResponse][google.cloud.dialogflow.cx.v3beta1.RunTestCaseResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.RunTestCaseRequest, dict]): The request object. The request message for @@ -656,6 +817,31 @@ async def batch_run_test_cases( - ``response``: [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3beta1.BatchRunTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.BatchRunTestCasesRequest, dict]): The request object. The request message for @@ -717,6 +903,26 @@ async def calculate_coverage( ) -> test_case.CalculateCoverageResponse: r"""Calculates the test coverage for an agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = client.calculate_coverage(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CalculateCoverageRequest, dict]): The request object. The request message for @@ -779,6 +985,31 @@ async def import_test_cases( - ``response``: [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3beta1.ImportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ImportTestCasesRequest, dict]): The request object. The request message for @@ -852,6 +1083,31 @@ async def export_test_cases( - ``response``: [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3beta1.ExportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ExportTestCasesRequest, dict]): The request object. The request message for @@ -914,6 +1170,26 @@ async def list_test_case_results( ) -> pagers.ListTestCaseResultsAsyncPager: r"""Fetches a list of results for a given test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListTestCaseResultsRequest, dict]): The request object. The request message for @@ -943,7 +1219,7 @@ async def list_test_case_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -996,6 +1272,25 @@ async def get_test_case_result( ) -> test_case.TestCaseResult: r"""Gets a test case result. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetTestCaseResultRequest, dict]): The request object. The request message for @@ -1020,7 +1315,7 @@ async def get_test_case_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/client.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/client.py index d5b83f46..f252dc7d 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -402,6 +402,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -452,57 +519,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, TestCasesTransport): # transport is a TestCasesTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -514,6 +546,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -537,6 +578,26 @@ def list_test_cases( ) -> pagers.ListTestCasesPager: r"""Fetches a list of test cases for a given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListTestCasesRequest, dict]): The request object. The request message for @@ -564,7 +625,7 @@ def list_test_cases( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -617,6 +678,23 @@ def batch_delete_test_cases( ) -> None: r"""Batch deletes test cases. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + client.batch_delete_test_cases(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.BatchDeleteTestCasesRequest, dict]): The request object. The request message for @@ -635,7 +713,7 @@ def batch_delete_test_cases( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -681,6 +759,25 @@ def get_test_case( ) -> test_case.TestCase: r"""Gets a test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetTestCaseRequest, dict]): The request object. The request message for @@ -703,7 +800,7 @@ def get_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -751,6 +848,29 @@ def create_test_case( ) -> gcdc_test_case.TestCase: r"""Creates a test case for the given agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = client.create_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateTestCaseRequest, dict]): The request object. The request message for @@ -778,7 +898,7 @@ def create_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, test_case]) if request is not None and has_flattened_params: @@ -828,6 +948,28 @@ def update_test_case( ) -> gcdc_test_case.TestCase: r"""Updates the specified test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = client.update_test_case(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateTestCaseRequest, dict]): The request object. The request message for @@ -859,7 +1001,7 @@ def update_test_case( Represents a test case. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([test_case, update_mask]) if request is not None and has_flattened_params: @@ -919,6 +1061,30 @@ def run_test_case( - ``response``: [RunTestCaseResponse][google.cloud.dialogflow.cx.v3beta1.RunTestCaseResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.RunTestCaseRequest, dict]): The request object. The request message for @@ -991,6 +1157,31 @@ def batch_run_test_cases( - ``response``: [BatchRunTestCasesResponse][google.cloud.dialogflow.cx.v3beta1.BatchRunTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.BatchRunTestCasesRequest, dict]): The request object. The request message for @@ -1053,6 +1244,26 @@ def calculate_coverage( ) -> test_case.CalculateCoverageResponse: r"""Calculates the test coverage for an agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = client.calculate_coverage(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CalculateCoverageRequest, dict]): The request object. The request message for @@ -1116,6 +1327,31 @@ def import_test_cases( - ``response``: [ImportTestCasesResponse][google.cloud.dialogflow.cx.v3beta1.ImportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ImportTestCasesRequest, dict]): The request object. The request message for @@ -1190,6 +1426,31 @@ def export_test_cases( - ``response``: [ExportTestCasesResponse][google.cloud.dialogflow.cx.v3beta1.ExportTestCasesResponse] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ExportTestCasesRequest, dict]): The request object. The request message for @@ -1253,6 +1514,26 @@ def list_test_case_results( ) -> pagers.ListTestCaseResultsPager: r"""Fetches a list of results for a given test case. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListTestCaseResultsRequest, dict]): The request object. The request message for @@ -1282,7 +1563,7 @@ def list_test_case_results( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1335,6 +1616,25 @@ def get_test_case_result( ) -> test_case.TestCaseResult: r"""Gets a test case result. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case_result(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetTestCaseResultRequest, dict]): The request object. The request message for @@ -1359,7 +1659,7 @@ def get_test_case_result( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/pagers.py index 638e7c29..74b78c52 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/__init__.py index caa2815b..10d2c977 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 4b707240..fbde19fb 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 85c59899..2ca83e62 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/test_cases/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -165,8 +165,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 a17cf52e..e812fb76 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -210,8 +210,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -241,7 +244,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/__init__.py index c5098c8b..629c785e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 8adfc542..8a7695ed 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -127,6 +127,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return TransitionRouteGroupsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> TransitionRouteGroupsTransport: """Returns the transport used by the client instance. @@ -202,6 +238,27 @@ async def list_transition_route_groups( r"""Returns the list of all transition route groups in the specified flow. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListTransitionRouteGroupsRequest, dict]): The request object. The request message for @@ -230,7 +287,7 @@ async def list_transition_route_groups( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -286,6 +343,26 @@ async def get_transition_route_group( r"""Retrieves the specified [TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -314,7 +391,7 @@ async def get_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -370,6 +447,30 @@ async def create_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.create_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -405,7 +506,7 @@ async def create_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, transition_route_group]) if request is not None and has_flattened_params: @@ -462,6 +563,29 @@ async def update_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.update_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -495,7 +619,7 @@ async def update_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([transition_route_group, update_mask]) if request is not None and has_flattened_params: @@ -553,6 +677,23 @@ async def delete_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_transition_route_group(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -573,7 +714,7 @@ async def delete_transition_route_group( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: 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 dd86fac2..0a4d133f 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -315,6 +315,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -365,57 +432,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, TransitionRouteGroupsTransport): # transport is a TransitionRouteGroupsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -427,6 +459,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -453,6 +494,27 @@ def list_transition_route_groups( r"""Returns the list of all transition route groups in the specified flow. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListTransitionRouteGroupsRequest, dict]): The request object. The request message for @@ -481,7 +543,7 @@ def list_transition_route_groups( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -541,6 +603,26 @@ def get_transition_route_group( r"""Retrieves the specified [TransitionRouteGroup][google.cloud.dialogflow.cx.v3beta1.TransitionRouteGroup]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -569,7 +651,7 @@ def get_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -629,6 +711,30 @@ def create_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.create_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -664,7 +770,7 @@ def create_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, transition_route_group]) if request is not None and has_flattened_params: @@ -727,6 +833,29 @@ def update_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.update_transition_route_group(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -760,7 +889,7 @@ def update_transition_route_group( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([transition_route_group, update_mask]) if request is not None and has_flattened_params: @@ -824,6 +953,23 @@ def delete_transition_route_group( queries. See the `training documentation `__. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_transition_route_group(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteTransitionRouteGroupRequest, dict]): The request object. The request message for @@ -844,7 +990,7 @@ def delete_transition_route_group( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/pagers.py index b57fc767..5c65c607 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/__init__.py index 1f1275f6..ed445782 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/transition_route_groups/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 653dc157..03a81824 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. 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 2aea0fb3..fc31f26f 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 b6a47f97..95d99a07 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 @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/versions/__init__.py index 586be181..78f73aa3 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py index 8550936d..14155659 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -108,6 +108,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return VersionsClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> VersionsTransport: """Returns the transport used by the client instance. @@ -180,6 +216,27 @@ async def list_versions( r"""Returns the list of all versions in the specified [Flow][google.cloud.dialogflow.cx.v3beta1.Flow]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListVersionsRequest, dict]): The request object. The request message for @@ -209,7 +266,7 @@ async def list_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -263,6 +320,26 @@ async def get_version( r"""Retrieves the specified [Version][google.cloud.dialogflow.cx.v3beta1.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetVersionRequest, dict]): The request object. The request message for @@ -287,7 +364,7 @@ async def get_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -347,6 +424,34 @@ async def create_version( - ``response``: [Version][google.cloud.dialogflow.cx.v3beta1.Version] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateVersionRequest, dict]): The request object. The request message for @@ -383,7 +488,7 @@ async def create_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, version]) if request is not None and has_flattened_params: @@ -442,6 +547,29 @@ async def update_version( r"""Updates the specified [Version][google.cloud.dialogflow.cx.v3beta1.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateVersionRequest, dict]): The request object. The request message for @@ -470,7 +598,7 @@ async def update_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([version, update_mask]) if request is not None and has_flattened_params: @@ -522,6 +650,23 @@ async def delete_version( r"""Deletes the specified [Version][google.cloud.dialogflow.cx.v3beta1.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + client.delete_version(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteVersionRequest, dict]): The request object. The request message for @@ -542,7 +687,7 @@ async def delete_version( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -598,6 +743,30 @@ async def load_version( - ``response``: An `Empty message `__ + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_load_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.LoadVersionRequest, dict]): The request object. The request message for @@ -637,7 +806,7 @@ async def load_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -693,6 +862,27 @@ async def compare_versions( r"""Compares the specified base version with target version. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = client.compare_versions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CompareVersionsRequest, dict]): The request object. The request message for @@ -721,7 +911,7 @@ async def compare_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([base_version]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/client.py b/google/cloud/dialogflowcx_v3beta1/services/versions/client.py index ca0f26a1..acf8b942 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -244,6 +244,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -294,57 +361,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, VersionsTransport): # transport is a VersionsTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -356,6 +388,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -380,6 +421,27 @@ def list_versions( r"""Returns the list of all versions in the specified [Flow][google.cloud.dialogflow.cx.v3beta1.Flow]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListVersionsRequest, dict]): The request object. The request message for @@ -409,7 +471,7 @@ def list_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -463,6 +525,26 @@ def get_version( r"""Retrieves the specified [Version][google.cloud.dialogflow.cx.v3beta1.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetVersionRequest, dict]): The request object. The request message for @@ -487,7 +569,7 @@ def get_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -547,6 +629,34 @@ def create_version( - ``response``: [Version][google.cloud.dialogflow.cx.v3beta1.Version] + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateVersionRequest, dict]): The request object. The request message for @@ -583,7 +693,7 @@ def create_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, version]) if request is not None and has_flattened_params: @@ -642,6 +752,29 @@ def update_version( r"""Updates the specified [Version][google.cloud.dialogflow.cx.v3beta1.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateVersionRequest, dict]): The request object. The request message for @@ -670,7 +803,7 @@ def update_version( Represents a version of a flow. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([version, update_mask]) if request is not None and has_flattened_params: @@ -722,6 +855,23 @@ def delete_version( r"""Deletes the specified [Version][google.cloud.dialogflow.cx.v3beta1.Version]. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + client.delete_version(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteVersionRequest, dict]): The request object. The request message for @@ -742,7 +892,7 @@ def delete_version( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -798,6 +948,30 @@ def load_version( - ``response``: An `Empty message `__ + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_load_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.LoadVersionRequest, dict]): The request object. The request message for @@ -837,7 +1011,7 @@ def load_version( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -893,6 +1067,27 @@ def compare_versions( r"""Compares the specified base version with target version. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = client.compare_versions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CompareVersionsRequest, dict]): The request object. The request message for @@ -921,7 +1116,7 @@ def compare_versions( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([base_version]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/versions/pagers.py index 839c0f71..3206dc4a 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/__init__.py index c5a42a0e..ab80b3b5 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py index 3c64f310..1008d2fd 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py index ae509b57..9e7d1655 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -164,8 +164,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) 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 72ac524d..4344d3d0 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/versions/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,8 +209,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, @@ -240,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/__init__.py index 28308a0b..7830ed1f 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/async_client.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/async_client.py index d8eb8978..d933c98e 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/async_client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -105,6 +105,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return WebhooksClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> WebhooksTransport: """Returns the transport used by the client instance. @@ -177,6 +213,27 @@ async def list_webhooks( r"""Returns the list of all webhooks in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListWebhooksRequest, dict]): The request object. The request message for @@ -204,7 +261,7 @@ async def list_webhooks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -257,6 +314,25 @@ async def get_webhook( ) -> webhook.Webhook: r"""Retrieves the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = client.get_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetWebhookRequest, dict]): The request object. The request message for @@ -286,7 +362,7 @@ async def get_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -334,6 +410,30 @@ async def create_webhook( ) -> gcdc_webhook.Webhook: r"""Creates a webhook in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = client.create_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateWebhookRequest, dict]): The request object. The request message for @@ -368,7 +468,7 @@ async def create_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, webhook]) if request is not None and has_flattened_params: @@ -418,6 +518,29 @@ async def update_webhook( ) -> gcdc_webhook.Webhook: r"""Updates the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = client.update_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateWebhookRequest, dict]): The request object. The request message for @@ -453,7 +576,7 @@ async def update_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([webhook, update_mask]) if request is not None and has_flattened_params: @@ -504,6 +627,22 @@ async def delete_webhook( ) -> None: r"""Deletes the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + client.delete_webhook(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteWebhookRequest, dict]): The request object. The request message for @@ -522,7 +661,7 @@ async def delete_webhook( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/client.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/client.py index 2e2b795b..bbacdd67 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/client.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -253,6 +253,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -303,57 +370,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, WebhooksTransport): # transport is a WebhooksTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -365,6 +397,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -389,6 +430,27 @@ def list_webhooks( r"""Returns the list of all webhooks in the specified agent. + + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.ListWebhooksRequest, dict]): The request object. The request message for @@ -416,7 +478,7 @@ def list_webhooks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -469,6 +531,25 @@ def get_webhook( ) -> webhook.Webhook: r"""Retrieves the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = client.get_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.GetWebhookRequest, dict]): The request object. The request message for @@ -498,7 +579,7 @@ def get_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -546,6 +627,30 @@ def create_webhook( ) -> gcdc_webhook.Webhook: r"""Creates a webhook in the specified agent. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = client.create_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.CreateWebhookRequest, dict]): The request object. The request message for @@ -580,7 +685,7 @@ def create_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, webhook]) if request is not None and has_flattened_params: @@ -630,6 +735,29 @@ def update_webhook( ) -> gcdc_webhook.Webhook: r"""Updates the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = client.update_webhook(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.UpdateWebhookRequest, dict]): The request object. The request message for @@ -665,7 +793,7 @@ def update_webhook( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([webhook, update_mask]) if request is not None and has_flattened_params: @@ -716,6 +844,22 @@ def delete_webhook( ) -> None: r"""Deletes the specified webhook. + .. code-block:: python + + from google.cloud import dialogflowcx_v3beta1 + + def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + client.delete_webhook(request=request) + Args: request (Union[google.cloud.dialogflowcx_v3beta1.types.DeleteWebhookRequest, dict]): The request object. The request message for @@ -734,7 +878,7 @@ def delete_webhook( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/pagers.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/pagers.py index 75a06fc6..bfa28b82 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/pagers.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/__init__.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/__init__.py index 17f318f9..2beebd10 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py index 2b40e905..4fa4a8dd 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py index 0a53c0c7..3f2ae596 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -161,8 +161,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 65a2c210..1f47dc56 100644 --- a/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py +++ b/google/cloud/dialogflowcx_v3beta1/services/webhooks/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -206,8 +206,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/dialogflowcx_v3beta1/types/__init__.py b/google/cloud/dialogflowcx_v3beta1/types/__init__.py index 50d69e71..f5baa497 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/__init__.py +++ b/google/cloud/dialogflowcx_v3beta1/types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/advanced_settings.py b/google/cloud/dialogflowcx_v3beta1/types/advanced_settings.py index f6308604..386f99d2 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/advanced_settings.py +++ b/google/cloud/dialogflowcx_v3beta1/types/advanced_settings.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/agent.py b/google/cloud/dialogflowcx_v3beta1/types/agent.py index bb9c7702..8e39df1b 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/agent.py +++ b/google/cloud/dialogflowcx_v3beta1/types/agent.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/audio_config.py b/google/cloud/dialogflowcx_v3beta1/types/audio_config.py index ec6d0a93..a6b80868 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/audio_config.py +++ b/google/cloud/dialogflowcx_v3beta1/types/audio_config.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/changelog.py b/google/cloud/dialogflowcx_v3beta1/types/changelog.py index c395ee56..aec0a816 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/changelog.py +++ b/google/cloud/dialogflowcx_v3beta1/types/changelog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/deployment.py b/google/cloud/dialogflowcx_v3beta1/types/deployment.py index 5f3b22f7..e354a042 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/deployment.py +++ b/google/cloud/dialogflowcx_v3beta1/types/deployment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/entity_type.py b/google/cloud/dialogflowcx_v3beta1/types/entity_type.py index 97ebff81..7017f026 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/entity_type.py +++ b/google/cloud/dialogflowcx_v3beta1/types/entity_type.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/environment.py b/google/cloud/dialogflowcx_v3beta1/types/environment.py index 886bcb2a..b526248b 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/environment.py +++ b/google/cloud/dialogflowcx_v3beta1/types/environment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/experiment.py b/google/cloud/dialogflowcx_v3beta1/types/experiment.py index 1f6a9315..e269e3cb 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/experiment.py +++ b/google/cloud/dialogflowcx_v3beta1/types/experiment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/flow.py b/google/cloud/dialogflowcx_v3beta1/types/flow.py index 83981de9..045c25a2 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/flow.py +++ b/google/cloud/dialogflowcx_v3beta1/types/flow.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/fulfillment.py b/google/cloud/dialogflowcx_v3beta1/types/fulfillment.py index 1da40862..36df0c57 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/fulfillment.py +++ b/google/cloud/dialogflowcx_v3beta1/types/fulfillment.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/intent.py b/google/cloud/dialogflowcx_v3beta1/types/intent.py index 7b7af076..0c0f8760 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/intent.py +++ b/google/cloud/dialogflowcx_v3beta1/types/intent.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/page.py b/google/cloud/dialogflowcx_v3beta1/types/page.py index 79863ac1..34066c8b 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/page.py +++ b/google/cloud/dialogflowcx_v3beta1/types/page.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/response_message.py b/google/cloud/dialogflowcx_v3beta1/types/response_message.py index d861e705..c27fbd10 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/response_message.py +++ b/google/cloud/dialogflowcx_v3beta1/types/response_message.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -107,8 +107,8 @@ class ResponseMessage(proto.Message): This field is a member of `oneof`_ ``message``. telephony_transfer_call (google.cloud.dialogflowcx_v3beta1.types.ResponseMessage.TelephonyTransferCall): A signal that the client should transfer the - phone call connected to this agent to a third- - party endpoint. + phone call connected to this agent to a + third-party endpoint. This field is a member of `oneof`_ ``message``. """ diff --git a/google/cloud/dialogflowcx_v3beta1/types/security_settings.py b/google/cloud/dialogflowcx_v3beta1/types/security_settings.py index 69eccf7f..de4ea3b0 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/security_settings.py +++ b/google/cloud/dialogflowcx_v3beta1/types/security_settings.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -255,7 +255,7 @@ class PurgeDataType(proto.Enum): class InsightsExportSettings(proto.Message): r"""Settings for exporting conversations to - `Insights `__. + `Insights `__. Attributes: enable_insights_export (bool): diff --git a/google/cloud/dialogflowcx_v3beta1/types/session.py b/google/cloud/dialogflowcx_v3beta1/types/session.py index 007ac4be..843580cf 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/session.py +++ b/google/cloud/dialogflowcx_v3beta1/types/session.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -479,10 +479,11 @@ class QueryParameters(proto.Message): the headers configured through Dialogflow console if there is a conflict. Header names are case-insensitive. Google's specified headers are - not allowed. Including: "Host", "Content- - Length", "Connection", "From", "User-Agent", - "Accept-Encoding", "If-Modified-Since", "If- - None-Match", "X-Forwarded-For", etc. + not allowed. Including: "Host", + "Content-Length", "Connection", "From", + "User-Agent", "Accept-Encoding", + "If-Modified-Since", "If-None-Match", + "X-Forwarded-For", etc. flow_versions (Sequence[str]): A list of flow versions to override for the request. Format: ``projects//locations//agents//flows//versions/``. @@ -799,9 +800,12 @@ class Match(proto.Message): [``INTENT``][google.cloud.dialogflow.cx.v3beta1.Match.MatchType] match type. event (str): - The event that matched the query. Only filled for - [``EVENT``][google.cloud.dialogflow.cx.v3beta1.Match.MatchType] - match type. + The event that matched the query. Filled for + [``EVENT``][google.cloud.dialogflow.cx.v3beta1.Match.MatchType], + [``NO_MATCH``][google.cloud.dialogflow.cx.v3beta1.Match.MatchType] + and + [``NO_INPUT``][google.cloud.dialogflow.cx.v3beta1.Match.MatchType] + match types. parameters (google.protobuf.struct_pb2.Struct): The collection of parameters extracted from the query. diff --git a/google/cloud/dialogflowcx_v3beta1/types/session_entity_type.py b/google/cloud/dialogflowcx_v3beta1/types/session_entity_type.py index 3d0ce711..7f4a8c1c 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/session_entity_type.py +++ b/google/cloud/dialogflowcx_v3beta1/types/session_entity_type.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/test_case.py b/google/cloud/dialogflowcx_v3beta1/types/test_case.py index 0159c503..5bb572a9 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/test_case.py +++ b/google/cloud/dialogflowcx_v3beta1/types/test_case.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/transition_route_group.py b/google/cloud/dialogflowcx_v3beta1/types/transition_route_group.py index 456e4bc3..91d5de03 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/transition_route_group.py +++ b/google/cloud/dialogflowcx_v3beta1/types/transition_route_group.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/validation_message.py b/google/cloud/dialogflowcx_v3beta1/types/validation_message.py index ee562f6d..3a864804 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/validation_message.py +++ b/google/cloud/dialogflowcx_v3beta1/types/validation_message.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/version.py b/google/cloud/dialogflowcx_v3beta1/types/version.py index 27b474cb..54257b02 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/version.py +++ b/google/cloud/dialogflowcx_v3beta1/types/version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/dialogflowcx_v3beta1/types/webhook.py b/google/cloud/dialogflowcx_v3beta1/types/webhook.py index ee318224..3fe876d4 100644 --- a/google/cloud/dialogflowcx_v3beta1/types/webhook.py +++ b/google/cloud/dialogflowcx_v3beta1/types/webhook.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/noxfile.py b/noxfile.py index ab589a7e..55cc38be 100644 --- a/noxfile.py +++ b/noxfile.py @@ -175,7 +175,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=99") + session.run("coverage", "report", "--show-missing", "--fail-under=100") session.run("coverage", "erase") diff --git a/owlbot.py b/owlbot.py index 62875a6f..388c8f89 100644 --- a/owlbot.py +++ b/owlbot.py @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,39 +12,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""This script is used to synthesize generated parts of this library.""" -import os - import synthtool as s import synthtool.gcp as gcp from synthtool.languages import python -common = gcp.CommonTemplates() +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- default_version = "v3" for library in s.get_staging_dirs(default_version): - s.move( - library, - excludes=[ - "setup.py", - "docs/index.rst", - "README.rst", - "noxfile.py", - f"scripts/fixup_dialogflowcx_{library.name}_keywords.py", - ], - ) + s.move(library, excludes=["setup.py", "README.rst"]) s.remove_staging_dirs() # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = common.py_library(cov_level=99, microgenerator=True) -python.py_samples(skip_readmes=True) -s.move( - templated_files, excludes=[".coveragerc"] -) # the microgenerator has a good coveragerc file + +templated_files = gcp.CommonTemplates().py_library( + microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), +) +s.move(templated_files, excludes=[".coveragerc"]) # the microgenerator has a good coveragerc file # ignore docs warnings (only fail on errors) s.replace( @@ -53,5 +44,10 @@ '' ) -s.shell.run(["nox", "-s", "blacken"], hide_output=False) +python.py_samples(skip_readmes=True) + +# ---------------------------------------------------------------------------- +# Run blacken session +# ---------------------------------------------------------------------------- +s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_async.py new file mode 100644 index 00000000..1f8ccdc9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_CreateAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = await client.create_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_CreateAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_sync.py new file mode 100644 index 00000000..32002c22 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_create_agent_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_CreateAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = client.create_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_CreateAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_async.py new file mode 100644 index 00000000..10173a94 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_DeleteAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + await client.delete_agent(request=request) + + +# [END dialogflow_v3_generated_Agents_DeleteAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_sync.py new file mode 100644 index 00000000..60e7eb6e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_delete_agent_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_DeleteAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + client.delete_agent(request=request) + + +# [END dialogflow_v3_generated_Agents_DeleteAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_async.py new file mode 100644 index 00000000..e98877b1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_ExportAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_export_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_ExportAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_sync.py new file mode 100644 index 00000000..7ea61dbe --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_export_agent_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_ExportAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_export_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_ExportAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_async.py new file mode 100644 index 00000000..81dafd1b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_GetAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_GetAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_sync.py new file mode 100644 index 00000000..5609c646 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_GetAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_GetAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_async.py new file mode 100644 index 00000000..2256dc78 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgentValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_GetAgentValidationResult_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_GetAgentValidationResult_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_sync.py new file mode 100644 index 00000000..b374e3f4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_get_agent_validation_result_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgentValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_GetAgentValidationResult_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_GetAgentValidationResult_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_async.py new file mode 100644 index 00000000..d942ac27 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAgents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_ListAgents_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_agents(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Agents_ListAgents_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_sync.py new file mode 100644 index 00000000..bfde1bb2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_list_agents_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAgents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_ListAgents_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_agents(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Agents_ListAgents_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_async.py new file mode 100644 index 00000000..da18ea57 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RestoreAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_RestoreAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_RestoreAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_sync.py new file mode 100644 index 00000000..b9f5072b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_restore_agent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RestoreAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_RestoreAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_RestoreAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_async.py new file mode 100644 index 00000000..2913aa32 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_UpdateAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = await client.update_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_UpdateAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_sync.py new file mode 100644 index 00000000..ba66a9f1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_update_agent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_UpdateAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = client.update_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_UpdateAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_async.py b/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_async.py new file mode 100644 index 00000000..9db824ae --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_ValidateAgent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = await client.validate_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_ValidateAgent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_sync.py b/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_sync.py new file mode 100644 index 00000000..8c489b42 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_agents_validate_agent_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Agents_ValidateAgent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = client.validate_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Agents_ValidateAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_async.py b/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_async.py new file mode 100644 index 00000000..77b87a80 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetChangelog +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Changelogs_GetChangelog_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3.ChangelogsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = await client.get_changelog(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Changelogs_GetChangelog_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_sync.py b/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_sync.py new file mode 100644 index 00000000..03ee33b0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_changelogs_get_changelog_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetChangelog +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Changelogs_GetChangelog_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = client.get_changelog(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Changelogs_GetChangelog_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_async.py b/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_async.py new file mode 100644 index 00000000..f50a2003 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListChangelogs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Changelogs_ListChangelogs_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3.ChangelogsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Changelogs_ListChangelogs_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_sync.py b/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_sync.py new file mode 100644 index 00000000..1960376f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_changelogs_list_changelogs_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListChangelogs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Changelogs_ListChangelogs_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Changelogs_ListChangelogs_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_async.py b/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_async.py new file mode 100644 index 00000000..b81dee60 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeployment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Deployments_GetDeployment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3.DeploymentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_deployment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Deployments_GetDeployment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_sync.py b/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_sync.py new file mode 100644 index 00000000..3e8abfae --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_deployments_get_deployment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeployment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Deployments_GetDeployment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Deployments_GetDeployment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_async.py b/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_async.py new file mode 100644 index 00000000..0f0f6515 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeployments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Deployments_ListDeployments_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3.DeploymentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Deployments_ListDeployments_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_sync.py b/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_sync.py new file mode 100644 index 00000000..ba368161 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_deployments_list_deployments_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeployments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Deployments_ListDeployments_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Deployments_ListDeployments_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_async.py new file mode 100644 index 00000000..212ac661 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_CreateEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesAsyncClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = await client.create_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_EntityTypes_CreateEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_sync.py new file mode 100644 index 00000000..8f1d61f6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_create_entity_type_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_CreateEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = client.create_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_EntityTypes_CreateEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_async.py new file mode 100644 index 00000000..bd513090 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_DeleteEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + await client.delete_entity_type(request=request) + + +# [END dialogflow_v3_generated_EntityTypes_DeleteEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_sync.py new file mode 100644 index 00000000..aae894e2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_delete_entity_type_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_DeleteEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_entity_type(request=request) + + +# [END dialogflow_v3_generated_EntityTypes_DeleteEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_async.py new file mode 100644 index 00000000..6892cc82 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_GetEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = await client.get_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_EntityTypes_GetEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_sync.py new file mode 100644 index 00000000..3b1ff44f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_get_entity_type_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_GetEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_EntityTypes_GetEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_async.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_async.py new file mode 100644 index 00000000..67acd173 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_ListEntityTypes_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3.EntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_EntityTypes_ListEntityTypes_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_sync.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_sync.py new file mode 100644 index 00000000..eb0bb09c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_list_entity_types_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_ListEntityTypes_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_EntityTypes_ListEntityTypes_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_async.py new file mode 100644 index 00000000..c8843b3c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_UpdateEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesAsyncClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = await client.update_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_EntityTypes_UpdateEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_sync.py new file mode 100644 index 00000000..44d05cd6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_entity_types_update_entity_type_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_EntityTypes_UpdateEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = client.update_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_EntityTypes_UpdateEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_async.py new file mode 100644 index 00000000..b4fe8fc8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_CreateEnvironment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_CreateEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_sync.py new file mode 100644 index 00000000..e4cfe6ee --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_create_environment_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_CreateEnvironment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_CreateEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_async.py new file mode 100644 index 00000000..e9ef0108 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_DeleteEnvironment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + await client.delete_environment(request=request) + + +# [END dialogflow_v3_generated_Environments_DeleteEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_sync.py new file mode 100644 index 00000000..f79f855b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_delete_environment_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_DeleteEnvironment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + client.delete_environment(request=request) + + +# [END dialogflow_v3_generated_Environments_DeleteEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_async.py new file mode 100644 index 00000000..66b0c393 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_DeployFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_DeployFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_sync.py new file mode 100644 index 00000000..e5605cdb --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_deploy_flow_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_DeployFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_DeployFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_async.py new file mode 100644 index 00000000..309bc18e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_GetEnvironment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_environment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_GetEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_sync.py new file mode 100644 index 00000000..b6ab849d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_get_environment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_GetEnvironment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = client.get_environment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_GetEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_async.py new file mode 100644 index 00000000..9261d768 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListContinuousTestResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_ListContinuousTestResults_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Environments_ListContinuousTestResults_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_sync.py new file mode 100644 index 00000000..cdd584ff --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_list_continuous_test_results_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListContinuousTestResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_ListContinuousTestResults_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Environments_ListContinuousTestResults_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_async.py new file mode 100644 index 00000000..6432e31a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEnvironments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_ListEnvironments_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_environments(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Environments_ListEnvironments_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_sync.py new file mode 100644 index 00000000..ea1991db --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_list_environments_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEnvironments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_ListEnvironments_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_environments(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Environments_ListEnvironments_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_async.py new file mode 100644 index 00000000..743b453b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LookupEnvironmentHistory +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_LookupEnvironmentHistory_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Environments_LookupEnvironmentHistory_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_sync.py new file mode 100644 index 00000000..631b64d9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_lookup_environment_history_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LookupEnvironmentHistory +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_LookupEnvironmentHistory_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Environments_LookupEnvironmentHistory_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_async.py new file mode 100644 index 00000000..796c2c27 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunContinuousTest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_RunContinuousTest_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_RunContinuousTest_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_sync.py new file mode 100644 index 00000000..3beaaaf0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_run_continuous_test_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunContinuousTest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_RunContinuousTest_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_RunContinuousTest_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_async.py b/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_async.py new file mode 100644 index 00000000..87dd4965 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_UpdateEnvironment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsAsyncClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_UpdateEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_sync.py b/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_sync.py new file mode 100644 index 00000000..f1fae9d7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_environments_update_environment_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Environments_UpdateEnvironment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_environment(): + # Create a client + client = dialogflowcx_v3.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Environments_UpdateEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_async.py new file mode 100644 index 00000000..6a876feb --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_CreateExperiment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = await client.create_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_CreateExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_sync.py new file mode 100644 index 00000000..7d582893 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_create_experiment_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_CreateExperiment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = client.create_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_CreateExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_async.py new file mode 100644 index 00000000..9f65bbfa --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_DeleteExperiment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + await client.delete_experiment(request=request) + + +# [END dialogflow_v3_generated_Experiments_DeleteExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_sync.py new file mode 100644 index 00000000..dc5b9593 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_delete_experiment_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_DeleteExperiment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + client.delete_experiment(request=request) + + +# [END dialogflow_v3_generated_Experiments_DeleteExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_async.py new file mode 100644 index 00000000..ad6572ac --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_GetExperiment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_GetExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_sync.py new file mode 100644 index 00000000..dc7e5eb6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_get_experiment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_GetExperiment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.get_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_GetExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_async.py new file mode 100644 index 00000000..e03b3a8c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListExperiments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_ListExperiments_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Experiments_ListExperiments_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_sync.py new file mode 100644 index 00000000..0bfa34e3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_list_experiments_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListExperiments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_ListExperiments_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Experiments_ListExperiments_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_async.py new file mode 100644 index 00000000..28ee720f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StartExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_StartExperiment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = await client.start_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_StartExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_sync.py new file mode 100644 index 00000000..27a7e934 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_start_experiment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StartExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_StartExperiment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.start_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_StartExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_async.py new file mode 100644 index 00000000..6cd3eac6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StopExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_StopExperiment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = await client.stop_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_StopExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_sync.py new file mode 100644 index 00000000..b37202c3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_stop_experiment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StopExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_StopExperiment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.stop_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_StopExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_async.py b/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_async.py new file mode 100644 index 00000000..cbada8e6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_UpdateExperiment_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsAsyncClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = await client.update_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_UpdateExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_sync.py b/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_sync.py new file mode 100644 index 00000000..672a8a9f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_experiments_update_experiment_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Experiments_UpdateExperiment_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = client.update_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Experiments_UpdateExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_async.py new file mode 100644 index 00000000..106b40c3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_CreateFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = await client.create_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_CreateFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_sync.py new file mode 100644 index 00000000..4e5dda1c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_create_flow_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_CreateFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = client.create_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_CreateFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_async.py new file mode 100644 index 00000000..3d344d3d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_DeleteFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + await client.delete_flow(request=request) + + +# [END dialogflow_v3_generated_Flows_DeleteFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_sync.py new file mode 100644 index 00000000..65852ed5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_delete_flow_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_DeleteFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + client.delete_flow(request=request) + + +# [END dialogflow_v3_generated_Flows_DeleteFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_async.py new file mode 100644 index 00000000..8dbf26a9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ExportFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_export_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_ExportFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_sync.py new file mode 100644 index 00000000..bf59c40b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_export_flow_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ExportFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_export_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_ExportFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_async.py new file mode 100644 index 00000000..dd88b6c0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_GetFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = await client.get_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_GetFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_sync.py new file mode 100644 index 00000000..60ab8ca2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_GetFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_GetFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_async.py new file mode 100644 index 00000000..10876cd4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlowValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_GetFlowValidationResult_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_GetFlowValidationResult_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_sync.py new file mode 100644 index 00000000..e3574f3a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlowValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_GetFlowValidationResult_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_GetFlowValidationResult_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_async.py new file mode 100644 index 00000000..7fa600a3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ImportFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_import_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_ImportFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_sync.py new file mode 100644 index 00000000..dff3a2e7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_import_flow_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ImportFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_import_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_ImportFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_async.py new file mode 100644 index 00000000..1e54b349 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFlows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ListFlows_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_flows(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Flows_ListFlows_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_sync.py new file mode 100644 index 00000000..eb9095c1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_list_flows_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFlows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ListFlows_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_flows(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Flows_ListFlows_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_async.py new file mode 100644 index 00000000..aeae5b3f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TrainFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_TrainFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_train_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_TrainFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_sync.py new file mode 100644 index 00000000..6dee111d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_train_flow_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TrainFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_TrainFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_train_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_TrainFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_async.py new file mode 100644 index 00000000..0a24982f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_UpdateFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = await client.update_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_UpdateFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_sync.py new file mode 100644 index 00000000..2d02f136 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_update_flow_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_UpdateFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = client.update_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_UpdateFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_async.py b/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_async.py new file mode 100644 index 00000000..c0c33a93 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ValidateFlow_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = await client.validate_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_ValidateFlow_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_sync.py b/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_sync.py new file mode 100644 index 00000000..ab10f5ac --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_flows_validate_flow_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Flows_ValidateFlow_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = client.validate_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Flows_ValidateFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_async.py new file mode 100644 index 00000000..2f1f855e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_CreateIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_intent(): + # Create a client + client = dialogflowcx_v3.IntentsAsyncClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = await client.create_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Intents_CreateIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_sync.py new file mode 100644 index 00000000..9ef0f25b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_create_intent_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_CreateIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = client.create_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Intents_CreateIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_async.py new file mode 100644 index 00000000..46308a78 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_DeleteIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3.IntentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + await client.delete_intent(request=request) + + +# [END dialogflow_v3_generated_Intents_DeleteIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_sync.py new file mode 100644 index 00000000..5c2b54ad --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_delete_intent_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_DeleteIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + client.delete_intent(request=request) + + +# [END dialogflow_v3_generated_Intents_DeleteIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_async.py new file mode 100644 index 00000000..ac93a95f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_GetIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_intent(): + # Create a client + client = dialogflowcx_v3.IntentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Intents_GetIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_sync.py new file mode 100644 index 00000000..fbe05873 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_get_intent_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_GetIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = client.get_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Intents_GetIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_async.py b/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_async.py new file mode 100644 index 00000000..0bc143c4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIntents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_ListIntents_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_intents(): + # Create a client + client = dialogflowcx_v3.IntentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Intents_ListIntents_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_sync.py b/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_sync.py new file mode 100644 index 00000000..8dde0807 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_list_intents_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIntents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_ListIntents_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_intents(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Intents_ListIntents_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_async.py new file mode 100644 index 00000000..ee944038 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_UpdateIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_intent(): + # Create a client + client = dialogflowcx_v3.IntentsAsyncClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = await client.update_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Intents_UpdateIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_sync.py new file mode 100644 index 00000000..40b2f14b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_intents_update_intent_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Intents_UpdateIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_intent(): + # Create a client + client = dialogflowcx_v3.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = client.update_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Intents_UpdateIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_create_page_async.py b/samples/generated_samples/dialogflow_v3_generated_pages_create_page_async.py new file mode 100644 index 00000000..6fdee018 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_create_page_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_CreatePage_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_page(): + # Create a client + client = dialogflowcx_v3.PagesAsyncClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = await client.create_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Pages_CreatePage_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_create_page_sync.py b/samples/generated_samples/dialogflow_v3_generated_pages_create_page_sync.py new file mode 100644 index 00000000..48b02ee6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_create_page_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_CreatePage_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = client.create_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Pages_CreatePage_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_async.py b/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_async.py new file mode 100644 index 00000000..7e60e18e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_DeletePage_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_page(): + # Create a client + client = dialogflowcx_v3.PagesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeletePageRequest( + name="name_value", + ) + + # Make the request + await client.delete_page(request=request) + + +# [END dialogflow_v3_generated_Pages_DeletePage_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_sync.py b/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_sync.py new file mode 100644 index 00000000..67b83c48 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_delete_page_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_DeletePage_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeletePageRequest( + name="name_value", + ) + + # Make the request + client.delete_page(request=request) + + +# [END dialogflow_v3_generated_Pages_DeletePage_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_get_page_async.py b/samples/generated_samples/dialogflow_v3_generated_pages_get_page_async.py new file mode 100644 index 00000000..8db4e796 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_get_page_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_GetPage_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_page(): + # Create a client + client = dialogflowcx_v3.PagesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetPageRequest( + name="name_value", + ) + + # Make the request + response = await client.get_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Pages_GetPage_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_get_page_sync.py b/samples/generated_samples/dialogflow_v3_generated_pages_get_page_sync.py new file mode 100644 index 00000000..69a39bed --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_get_page_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_GetPage_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetPageRequest( + name="name_value", + ) + + # Make the request + response = client.get_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Pages_GetPage_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_async.py b/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_async.py new file mode 100644 index 00000000..aaddeed0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_ListPages_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_pages(): + # Create a client + client = dialogflowcx_v3.PagesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Pages_ListPages_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_sync.py b/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_sync.py new file mode 100644 index 00000000..13581a3c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_list_pages_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_ListPages_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_pages(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Pages_ListPages_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_update_page_async.py b/samples/generated_samples/dialogflow_v3_generated_pages_update_page_async.py new file mode 100644 index 00000000..b72d1529 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_update_page_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_UpdatePage_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_page(): + # Create a client + client = dialogflowcx_v3.PagesAsyncClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdatePageRequest( + page=page, + ) + + # Make the request + response = await client.update_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Pages_UpdatePage_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_pages_update_page_sync.py b/samples/generated_samples/dialogflow_v3_generated_pages_update_page_sync.py new file mode 100644 index 00000000..40ea8b2e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_pages_update_page_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Pages_UpdatePage_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_page(): + # Create a client + client = dialogflowcx_v3.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdatePageRequest( + page=page, + ) + + # Make the request + response = client.update_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Pages_UpdatePage_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_async.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_async.py new file mode 100644 index 00000000..12c69c0e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = await client.create_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_sync.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_sync.py new file mode 100644 index 00000000..79affad0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_create_security_settings_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = client.create_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_async.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_async.py new file mode 100644 index 00000000..20ec54de --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + await client.delete_security_settings(request=request) + + +# [END dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_sync.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_sync.py new file mode 100644 index 00000000..2efa575c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_delete_security_settings_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + client.delete_security_settings(request=request) + + +# [END dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_async.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_async.py new file mode 100644 index 00000000..053cd6b3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = await client.get_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_sync.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_sync.py new file mode 100644 index 00000000..86805d9c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_get_security_settings_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_async.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_async.py new file mode 100644 index 00000000..62526f38 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_sync.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_sync.py new file mode 100644 index 00000000..3ae5c74b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_list_security_settings_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_async.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_async.py new file mode 100644 index 00000000..981e4fa7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = await client.update_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_sync.py b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_sync.py new file mode 100644 index 00000000..15241a90 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_security_settings_service_update_security_settings_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = client.update_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_async.py new file mode 100644 index 00000000..3c3b3102 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = await client.create_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_sync.py new file mode 100644 index 00000000..43689cfc --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_create_session_entity_type_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.create_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_async.py new file mode 100644 index 00000000..4baac182 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + await client.delete_session_entity_type(request=request) + + +# [END dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_sync.py new file mode 100644 index 00000000..fe78bad1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_delete_session_entity_type_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_session_entity_type(request=request) + + +# [END dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_async.py new file mode 100644 index 00000000..1bfe5a5d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = await client.get_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_sync.py new file mode 100644 index 00000000..c0627549 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_get_session_entity_type_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_async.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_async.py new file mode 100644 index 00000000..b5659658 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSessionEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_sync.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_sync.py new file mode 100644 index 00000000..d0dc5b8a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_list_session_entity_types_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSessionEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_async.py new file mode 100644 index 00000000..0892fffe --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = await client.update_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_sync.py new file mode 100644 index 00000000..6e6f07fc --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_session_entity_types_update_session_entity_type_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.update_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_async.py new file mode 100644 index 00000000..2fe01ac7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_DetectIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsAsyncClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = await client.detect_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Sessions_DetectIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_sync.py new file mode 100644 index 00000000..1b7be656 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_detect_intent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_DetectIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.detect_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Sessions_DetectIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_async.py new file mode 100644 index 00000000..1e3e5a73 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FulfillIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_FulfillIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3.SessionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.FulfillIntentRequest( + ) + + # Make the request + response = await client.fulfill_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Sessions_FulfillIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_sync.py new file mode 100644 index 00000000..963d2dab --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_fulfill_intent_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FulfillIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_FulfillIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.FulfillIntentRequest( + ) + + # Make the request + response = client.fulfill_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Sessions_FulfillIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_async.py new file mode 100644 index 00000000..0145534d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for MatchIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_MatchIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_match_intent(): + # Create a client + client = dialogflowcx_v3.SessionsAsyncClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = await client.match_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Sessions_MatchIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_sync.py new file mode 100644 index 00000000..e1fd21f6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_match_intent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for MatchIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_MatchIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_match_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.match_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Sessions_MatchIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_async.py b/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_async.py new file mode 100644 index 00000000..3f3d459d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StreamingDetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_StreamingDetectIntent_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsAsyncClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = await client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + async for response in stream: + print(response) + +# [END dialogflow_v3_generated_Sessions_StreamingDetectIntent_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_sync.py b/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_sync.py new file mode 100644 index 00000000..83b40637 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_sessions_streaming_detect_intent_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StreamingDetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Sessions_StreamingDetectIntent_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + for response in stream: + print(response) + +# [END dialogflow_v3_generated_Sessions_StreamingDetectIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_async.py new file mode 100644 index 00000000..94814902 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_BatchDeleteTestCases_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + await client.batch_delete_test_cases(request=request) + + +# [END dialogflow_v3_generated_TestCases_BatchDeleteTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_sync.py new file mode 100644 index 00000000..945ebded --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_delete_test_cases_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_BatchDeleteTestCases_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + client.batch_delete_test_cases(request=request) + + +# [END dialogflow_v3_generated_TestCases_BatchDeleteTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_async.py new file mode 100644 index 00000000..23812c8a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchRunTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_BatchRunTestCases_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_BatchRunTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_sync.py new file mode 100644 index 00000000..4a0052e6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_batch_run_test_cases_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchRunTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_BatchRunTestCases_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_BatchRunTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_async.py new file mode 100644 index 00000000..e7e89156 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateCoverage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_CalculateCoverage_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = await client.calculate_coverage(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_CalculateCoverage_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_sync.py new file mode 100644 index 00000000..6be6addd --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_calculate_coverage_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateCoverage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_CalculateCoverage_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = client.calculate_coverage(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_CalculateCoverage_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_async.py new file mode 100644 index 00000000..94bedcaa --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_CreateTestCase_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = await client.create_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_CreateTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_sync.py new file mode 100644 index 00000000..eedac60c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_create_test_case_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_CreateTestCase_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = client.create_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_CreateTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_async.py new file mode 100644 index 00000000..56c0bb5e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ExportTestCases_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_ExportTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_sync.py new file mode 100644 index 00000000..3ea2d561 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_export_test_cases_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ExportTestCases_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_ExportTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_async.py new file mode 100644 index 00000000..77336cd5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_GetTestCase_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = await client.get_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_GetTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_async.py new file mode 100644 index 00000000..2da50bd8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCaseResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_GetTestCaseResult_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_test_case_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_GetTestCaseResult_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_sync.py new file mode 100644 index 00000000..59468c75 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_result_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCaseResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_GetTestCaseResult_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_GetTestCaseResult_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_sync.py new file mode 100644 index 00000000..09a07cc5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_get_test_case_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_GetTestCase_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_GetTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_async.py new file mode 100644 index 00000000..9e8d8422 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ImportTestCases_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_ImportTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_sync.py new file mode 100644 index 00000000..cc71b5e5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_import_test_cases_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ImportTestCases_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_ImportTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_async.py new file mode 100644 index 00000000..e13f98b7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCaseResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ListTestCaseResults_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_TestCases_ListTestCaseResults_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_sync.py new file mode 100644 index 00000000..55c1d299 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_case_results_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCaseResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ListTestCaseResults_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_TestCases_ListTestCaseResults_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_async.py new file mode 100644 index 00000000..e7f91e78 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ListTestCases_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_TestCases_ListTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_sync.py new file mode 100644 index 00000000..d5a5b7ee --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_list_test_cases_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_ListTestCases_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_TestCases_ListTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_async.py new file mode 100644 index 00000000..9f6a0af8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_RunTestCase_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_RunTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_sync.py new file mode 100644 index 00000000..e45acfcd --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_run_test_case_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_RunTestCase_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_RunTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_async.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_async.py new file mode 100644 index 00000000..99e9ee97 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_UpdateTestCase_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesAsyncClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = await client.update_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_UpdateTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_sync.py b/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_sync.py new file mode 100644 index 00000000..f06dc4bd --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_test_cases_update_test_case_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TestCases_UpdateTestCase_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = client.update_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TestCases_UpdateTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_async.py new file mode 100644 index 00000000..4d00cda9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = await client.create_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_sync.py new file mode 100644 index 00000000..05ede2ae --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_create_transition_route_group_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.create_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_async.py new file mode 100644 index 00000000..b97d323f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + await client.delete_transition_route_group(request=request) + + +# [END dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_sync.py new file mode 100644 index 00000000..11cdcd41 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_transition_route_group(request=request) + + +# [END dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_async.py new file mode 100644 index 00000000..e1b150ce --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_sync.py new file mode 100644 index 00000000..24892d85 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_get_transition_route_group_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_async.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_async.py new file mode 100644 index 00000000..774275d0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTransitionRouteGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_sync.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_sync.py new file mode 100644 index 00000000..e8914f44 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTransitionRouteGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_async.py new file mode 100644 index 00000000..7bc9150e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = await client.update_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_sync.py new file mode 100644 index 00000000..50106bbc --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_transition_route_groups_update_transition_route_group_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.update_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_async.py new file mode 100644 index 00000000..3fbfd5be --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CompareVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_CompareVersions_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = await client.compare_versions(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_CompareVersions_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_sync.py new file mode 100644 index 00000000..5504f6e3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_compare_versions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CompareVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_CompareVersions_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = client.compare_versions(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_CompareVersions_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_create_version_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_create_version_async.py new file mode 100644 index 00000000..4d002b32 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_create_version_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_CreateVersion_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_version(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_CreateVersion_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_create_version_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_create_version_sync.py new file mode 100644 index 00000000..9e484429 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_create_version_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_CreateVersion_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_CreateVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_async.py new file mode 100644 index 00000000..92a43f5c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_DeleteVersion_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_version(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + await client.delete_version(request=request) + + +# [END dialogflow_v3_generated_Versions_DeleteVersion_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_sync.py new file mode 100644 index 00000000..053e885b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_delete_version_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_DeleteVersion_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + client.delete_version(request=request) + + +# [END dialogflow_v3_generated_Versions_DeleteVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_get_version_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_get_version_async.py new file mode 100644 index 00000000..0f4a1200 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_get_version_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_GetVersion_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_version(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_GetVersion_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_get_version_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_get_version_sync.py new file mode 100644 index 00000000..863e1536 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_get_version_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_GetVersion_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_GetVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_async.py new file mode 100644 index 00000000..2235dbd1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_ListVersions_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_versions(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Versions_ListVersions_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_sync.py new file mode 100644 index 00000000..7bfa0bc4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_list_versions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_ListVersions_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_versions(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Versions_ListVersions_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_load_version_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_load_version_async.py new file mode 100644 index 00000000..e2b76924 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_load_version_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LoadVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_LoadVersion_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_load_version(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_LoadVersion_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_load_version_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_load_version_sync.py new file mode 100644 index 00000000..445861a8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_load_version_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LoadVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_LoadVersion_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_load_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_LoadVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_update_version_async.py b/samples/generated_samples/dialogflow_v3_generated_versions_update_version_async.py new file mode 100644 index 00000000..362c49a2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_update_version_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_UpdateVersion_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_version(): + # Create a client + client = dialogflowcx_v3.VersionsAsyncClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = await client.update_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_UpdateVersion_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_versions_update_version_sync.py b/samples/generated_samples/dialogflow_v3_generated_versions_update_version_sync.py new file mode 100644 index 00000000..3eb6b403 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_versions_update_version_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Versions_UpdateVersion_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_version(): + # Create a client + client = dialogflowcx_v3.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Versions_UpdateVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_async.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_async.py new file mode 100644 index 00000000..ce8afc3b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_CreateWebhook_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksAsyncClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = await client.create_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Webhooks_CreateWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_sync.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_sync.py new file mode 100644 index 00000000..e144a5e7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_create_webhook_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_CreateWebhook_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = client.create_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Webhooks_CreateWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_async.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_async.py new file mode 100644 index 00000000..11cf83c2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_DeleteWebhook_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + await client.delete_webhook(request=request) + + +# [END dialogflow_v3_generated_Webhooks_DeleteWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_sync.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_sync.py new file mode 100644 index 00000000..e4ccacb0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_delete_webhook_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_DeleteWebhook_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + client.delete_webhook(request=request) + + +# [END dialogflow_v3_generated_Webhooks_DeleteWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_async.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_async.py new file mode 100644 index 00000000..39d4c5a0 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_GetWebhook_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = await client.get_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Webhooks_GetWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_sync.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_sync.py new file mode 100644 index 00000000..dcfdd5b9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_get_webhook_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_GetWebhook_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = client.get_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Webhooks_GetWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_async.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_async.py new file mode 100644 index 00000000..49c01247 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListWebhooks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_ListWebhooks_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3.WebhooksAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Webhooks_ListWebhooks_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_sync.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_sync.py new file mode 100644 index 00000000..679bac6e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_list_webhooks_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListWebhooks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_ListWebhooks_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3_generated_Webhooks_ListWebhooks_sync] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_async.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_async.py new file mode 100644 index 00000000..e32d86bb --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_UpdateWebhook_async] +from google.cloud import dialogflowcx_v3 + + +async def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksAsyncClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = await client.update_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Webhooks_UpdateWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_sync.py b/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_sync.py new file mode 100644 index 00000000..8e3ab173 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3_generated_webhooks_update_webhook_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3_generated_Webhooks_UpdateWebhook_sync] +from google.cloud import dialogflowcx_v3 + + +def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = client.update_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3_generated_Webhooks_UpdateWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_async.py new file mode 100644 index 00000000..cb436802 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_CreateAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = await client.create_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_CreateAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_sync.py new file mode 100644 index 00000000..4a925181 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_create_agent_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_CreateAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.CreateAgentRequest( + parent="parent_value", + agent=agent, + ) + + # Make the request + response = client.create_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_CreateAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_async.py new file mode 100644 index 00000000..0dccd8be --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_DeleteAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + await client.delete_agent(request=request) + + +# [END dialogflow_v3beta1_generated_Agents_DeleteAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_sync.py new file mode 100644 index 00000000..8ed319d2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_delete_agent_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_DeleteAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteAgentRequest( + name="name_value", + ) + + # Make the request + client.delete_agent(request=request) + + +# [END dialogflow_v3beta1_generated_Agents_DeleteAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_async.py new file mode 100644 index 00000000..5f2a4fa4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_ExportAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_export_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_ExportAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_sync.py new file mode 100644 index 00000000..d68eaeb2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_export_agent_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_ExportAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_export_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportAgentRequest( + name="name_value", + ) + + # Make the request + operation = client.export_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_ExportAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_async.py new file mode 100644 index 00000000..8113180c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_GetAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_GetAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_sync.py new file mode 100644 index 00000000..7eec2b16 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_GetAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_GetAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_async.py new file mode 100644 index 00000000..2245e5a6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgentValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_GetAgentValidationResult_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_GetAgentValidationResult_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_sync.py new file mode 100644 index 00000000..193ebdee --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_get_agent_validation_result_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetAgentValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_GetAgentValidationResult_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_agent_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetAgentValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_agent_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_GetAgentValidationResult_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_async.py new file mode 100644 index 00000000..ccda1682 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAgents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_ListAgents_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_agents(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Agents_ListAgents_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_sync.py new file mode 100644 index 00000000..7340a2e9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_list_agents_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListAgents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_ListAgents_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_agents(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListAgentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_agents(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Agents_ListAgents_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_async.py new file mode 100644 index 00000000..efa51489 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RestoreAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_RestoreAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_RestoreAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_sync.py new file mode 100644 index 00000000..3e82269a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_restore_agent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RestoreAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_RestoreAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_restore_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RestoreAgentRequest( + agent_uri="agent_uri_value", + name="name_value", + ) + + # Make the request + operation = client.restore_agent(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_RestoreAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_async.py new file mode 100644 index 00000000..aca120d1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_UpdateAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = await client.update_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_UpdateAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_sync.py new file mode 100644 index 00000000..5e42bb98 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_update_agent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_UpdateAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + agent = dialogflowcx_v3beta1.Agent() + agent.display_name = "display_name_value" + agent.default_language_code = "default_language_code_value" + agent.time_zone = "time_zone_value" + + request = dialogflowcx_v3beta1.UpdateAgentRequest( + agent=agent, + ) + + # Make the request + response = client.update_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_UpdateAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_async.py new file mode 100644 index 00000000..4a92ace4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_ValidateAgent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = await client.validate_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_ValidateAgent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_sync.py new file mode 100644 index 00000000..a849f096 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_agents_validate_agent_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateAgent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Agents_ValidateAgent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_validate_agent(): + # Create a client + client = dialogflowcx_v3beta1.AgentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateAgentRequest( + name="name_value", + ) + + # Make the request + response = client.validate_agent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Agents_ValidateAgent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_async.py new file mode 100644 index 00000000..60b5d892 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetChangelog +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Changelogs_GetChangelog_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = await client.get_changelog(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Changelogs_GetChangelog_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_sync.py new file mode 100644 index 00000000..e2e0ac6c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_get_changelog_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetChangelog +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Changelogs_GetChangelog_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_changelog(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetChangelogRequest( + name="name_value", + ) + + # Make the request + response = client.get_changelog(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Changelogs_GetChangelog_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_async.py new file mode 100644 index 00000000..a049aa4b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListChangelogs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Changelogs_ListChangelogs_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Changelogs_ListChangelogs_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_sync.py new file mode 100644 index 00000000..5c8d969a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_changelogs_list_changelogs_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListChangelogs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Changelogs_ListChangelogs_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_changelogs(): + # Create a client + client = dialogflowcx_v3beta1.ChangelogsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListChangelogsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_changelogs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Changelogs_ListChangelogs_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_async.py new file mode 100644 index 00000000..ee98c97f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeployment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Deployments_GetDeployment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_deployment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Deployments_GetDeployment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_sync.py new file mode 100644 index 00000000..a0691653 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_get_deployment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeployment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Deployments_GetDeployment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_deployment(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetDeploymentRequest( + name="name_value", + ) + + # Make the request + response = client.get_deployment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Deployments_GetDeployment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_async.py new file mode 100644 index 00000000..3f2b3715 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeployments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Deployments_ListDeployments_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Deployments_ListDeployments_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_sync.py new file mode 100644 index 00000000..a1947102 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_deployments_list_deployments_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeployments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Deployments_ListDeployments_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_deployments(): + # Create a client + client = dialogflowcx_v3beta1.DeploymentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListDeploymentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_deployments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Deployments_ListDeployments_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_async.py new file mode 100644 index 00000000..34af9294 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_CreateEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesAsyncClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = await client.create_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_CreateEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_sync.py new file mode 100644 index 00000000..944eee59 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_create_entity_type_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_CreateEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.CreateEntityTypeRequest( + parent="parent_value", + entity_type=entity_type, + ) + + # Make the request + response = client.create_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_CreateEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_async.py new file mode 100644 index 00000000..1abac912 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_DeleteEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + await client.delete_entity_type(request=request) + + +# [END dialogflow_v3beta1_generated_EntityTypes_DeleteEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_sync.py new file mode 100644 index 00000000..d4571184 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_delete_entity_type_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_DeleteEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_entity_type(request=request) + + +# [END dialogflow_v3beta1_generated_EntityTypes_DeleteEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_async.py new file mode 100644 index 00000000..591971ed --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_GetEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = await client.get_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_GetEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_sync.py new file mode 100644 index 00000000..e397ea89 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_get_entity_type_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_GetEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_GetEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_async.py new file mode 100644 index 00000000..ab05a6da --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_ListEntityTypes_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_ListEntityTypes_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_sync.py new file mode 100644 index 00000000..421db660 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_list_entity_types_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_ListEntityTypes_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_ListEntityTypes_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_async.py new file mode 100644 index 00000000..5d4e94ec --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_UpdateEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesAsyncClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = await client.update_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_UpdateEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_sync.py new file mode 100644 index 00000000..82112f41 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_entity_types_update_entity_type_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_EntityTypes_UpdateEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.EntityTypesClient() + + # Initialize request argument(s) + entity_type = dialogflowcx_v3beta1.EntityType() + entity_type.display_name = "display_name_value" + entity_type.kind = "KIND_REGEXP" + + request = dialogflowcx_v3beta1.UpdateEntityTypeRequest( + entity_type=entity_type, + ) + + # Make the request + response = client.update_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_EntityTypes_UpdateEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_async.py new file mode 100644 index 00000000..a80547a5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_CreateEnvironment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_CreateEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_sync.py new file mode 100644 index 00000000..42b68bce --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_create_environment_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_CreateEnvironment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.CreateEnvironmentRequest( + parent="parent_value", + environment=environment, + ) + + # Make the request + operation = client.create_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_CreateEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_async.py new file mode 100644 index 00000000..941441da --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_DeleteEnvironment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + await client.delete_environment(request=request) + + +# [END dialogflow_v3beta1_generated_Environments_DeleteEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_sync.py new file mode 100644 index 00000000..07e3cbb6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_delete_environment_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_DeleteEnvironment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteEnvironmentRequest( + name="name_value", + ) + + # Make the request + client.delete_environment(request=request) + + +# [END dialogflow_v3beta1_generated_Environments_DeleteEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_async.py new file mode 100644 index 00000000..a02293ec --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_DeployFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_DeployFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_sync.py new file mode 100644 index 00000000..1bbcf6ae --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_deploy_flow_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeployFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_DeployFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_deploy_flow(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeployFlowRequest( + environment="environment_value", + flow_version="flow_version_value", + ) + + # Make the request + operation = client.deploy_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_DeployFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_async.py new file mode 100644 index 00000000..6a6b6ffa --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_GetEnvironment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_environment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_GetEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_sync.py new file mode 100644 index 00000000..6fcd28b5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_get_environment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_GetEnvironment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetEnvironmentRequest( + name="name_value", + ) + + # Make the request + response = client.get_environment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_GetEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_async.py new file mode 100644 index 00000000..1a4093e1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListContinuousTestResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_ListContinuousTestResults_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Environments_ListContinuousTestResults_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_sync.py new file mode 100644 index 00000000..2db43598 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_continuous_test_results_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListContinuousTestResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_ListContinuousTestResults_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_continuous_test_results(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListContinuousTestResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_continuous_test_results(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Environments_ListContinuousTestResults_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_async.py new file mode 100644 index 00000000..b1fa7167 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEnvironments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_ListEnvironments_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_environments(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Environments_ListEnvironments_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_sync.py new file mode 100644 index 00000000..68348e71 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_list_environments_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListEnvironments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_ListEnvironments_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_environments(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListEnvironmentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_environments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Environments_ListEnvironments_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_async.py new file mode 100644 index 00000000..a03b3a25 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LookupEnvironmentHistory +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_LookupEnvironmentHistory_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Environments_LookupEnvironmentHistory_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_sync.py new file mode 100644 index 00000000..7d89e3e6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_lookup_environment_history_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LookupEnvironmentHistory +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_LookupEnvironmentHistory_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_lookup_environment_history(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LookupEnvironmentHistoryRequest( + name="name_value", + ) + + # Make the request + page_result = client.lookup_environment_history(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Environments_LookupEnvironmentHistory_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_async.py new file mode 100644 index 00000000..a16e5d07 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunContinuousTest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_RunContinuousTest_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_RunContinuousTest_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_sync.py new file mode 100644 index 00000000..ee042bc8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_run_continuous_test_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunContinuousTest +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_RunContinuousTest_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_run_continuous_test(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunContinuousTestRequest( + environment="environment_value", + ) + + # Make the request + operation = client.run_continuous_test(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_RunContinuousTest_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_async.py new file mode 100644 index 00000000..3c6a2350 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_UpdateEnvironment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsAsyncClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_UpdateEnvironment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_sync.py new file mode 100644 index 00000000..11b4e0b7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_environments_update_environment_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateEnvironment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Environments_UpdateEnvironment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_environment(): + # Create a client + client = dialogflowcx_v3beta1.EnvironmentsClient() + + # Initialize request argument(s) + environment = dialogflowcx_v3beta1.Environment() + environment.display_name = "display_name_value" + environment.version_configs.version = "version_value" + + request = dialogflowcx_v3beta1.UpdateEnvironmentRequest( + environment=environment, + ) + + # Make the request + operation = client.update_environment(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Environments_UpdateEnvironment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_async.py new file mode 100644 index 00000000..0b948468 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_CreateExperiment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = await client.create_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_CreateExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_sync.py new file mode 100644 index 00000000..2be07e08 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_create_experiment_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_CreateExperiment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateExperimentRequest( + parent="parent_value", + experiment=experiment, + ) + + # Make the request + response = client.create_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_CreateExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_async.py new file mode 100644 index 00000000..6dccaa1d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_DeleteExperiment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + await client.delete_experiment(request=request) + + +# [END dialogflow_v3beta1_generated_Experiments_DeleteExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_sync.py new file mode 100644 index 00000000..fa9fc241 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_delete_experiment_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_DeleteExperiment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteExperimentRequest( + name="name_value", + ) + + # Make the request + client.delete_experiment(request=request) + + +# [END dialogflow_v3beta1_generated_Experiments_DeleteExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_async.py new file mode 100644 index 00000000..2e2a9877 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_GetExperiment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_GetExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_sync.py new file mode 100644 index 00000000..bc2a86b6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_get_experiment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_GetExperiment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.get_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_GetExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_async.py new file mode 100644 index 00000000..574cc2a8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListExperiments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_ListExperiments_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_ListExperiments_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_sync.py new file mode 100644 index 00000000..9d6fc263 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_list_experiments_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListExperiments +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_ListExperiments_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_experiments(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListExperimentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_experiments(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_ListExperiments_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_async.py new file mode 100644 index 00000000..f1c2db2d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StartExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_StartExperiment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = await client.start_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_StartExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_sync.py new file mode 100644 index 00000000..149bd6d1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_start_experiment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StartExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_StartExperiment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_start_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StartExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.start_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_StartExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_async.py new file mode 100644 index 00000000..9abc4215 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StopExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_StopExperiment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = await client.stop_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_StopExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_sync.py new file mode 100644 index 00000000..ba88af5c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_stop_experiment_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StopExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_StopExperiment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_stop_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.StopExperimentRequest( + name="name_value", + ) + + # Make the request + response = client.stop_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_StopExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_async.py new file mode 100644 index 00000000..c3ca1274 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_UpdateExperiment_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsAsyncClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = await client.update_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_UpdateExperiment_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_sync.py new file mode 100644 index 00000000..cf56e7c8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_experiments_update_experiment_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExperiment +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Experiments_UpdateExperiment_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_experiment(): + # Create a client + client = dialogflowcx_v3beta1.ExperimentsClient() + + # Initialize request argument(s) + experiment = dialogflowcx_v3beta1.Experiment() + experiment.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateExperimentRequest( + experiment=experiment, + ) + + # Make the request + response = client.update_experiment(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Experiments_UpdateExperiment_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_async.py new file mode 100644 index 00000000..0eeb7480 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_CreateFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = await client.create_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_CreateFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_sync.py new file mode 100644 index 00000000..11fcf853 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_create_flow_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_CreateFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateFlowRequest( + parent="parent_value", + flow=flow, + ) + + # Make the request + response = client.create_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_CreateFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_async.py new file mode 100644 index 00000000..ed0fb0d2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_DeleteFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + await client.delete_flow(request=request) + + +# [END dialogflow_v3beta1_generated_Flows_DeleteFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_sync.py new file mode 100644 index 00000000..a208538a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_delete_flow_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_DeleteFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteFlowRequest( + name="name_value", + ) + + # Make the request + client.delete_flow(request=request) + + +# [END dialogflow_v3beta1_generated_Flows_DeleteFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_async.py new file mode 100644 index 00000000..137fb78f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ExportFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_export_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ExportFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_sync.py new file mode 100644 index 00000000..fbc3d8ee --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_export_flow_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ExportFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_export_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.export_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ExportFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_async.py new file mode 100644 index 00000000..f4cbd3a8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_GetFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = await client.get_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_GetFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_sync.py new file mode 100644 index 00000000..47f5a402 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_GetFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_GetFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_async.py new file mode 100644 index 00000000..3772f39f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlowValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_GetFlowValidationResult_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_GetFlowValidationResult_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_sync.py new file mode 100644 index 00000000..2f27817f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_get_flow_validation_result_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFlowValidationResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_GetFlowValidationResult_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_flow_validation_result(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetFlowValidationResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_flow_validation_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_GetFlowValidationResult_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_async.py new file mode 100644 index 00000000..e7318bdf --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ImportFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_import_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ImportFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_sync.py new file mode 100644 index 00000000..8028274b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_import_flow_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ImportFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_import_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportFlowRequest( + flow_uri="flow_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ImportFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_async.py new file mode 100644 index 00000000..8ba6f801 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFlows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ListFlows_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_flows(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ListFlows_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_sync.py new file mode 100644 index 00000000..55506a34 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_list_flows_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFlows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ListFlows_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_flows(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListFlowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_flows(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ListFlows_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_async.py new file mode 100644 index 00000000..edc6ea99 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TrainFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_TrainFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_train_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_TrainFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_sync.py new file mode 100644 index 00000000..78a7f5db --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_train_flow_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TrainFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_TrainFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_train_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.TrainFlowRequest( + name="name_value", + ) + + # Make the request + operation = client.train_flow(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_TrainFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_async.py new file mode 100644 index 00000000..2b0ffad5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_UpdateFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = await client.update_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_UpdateFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_sync.py new file mode 100644 index 00000000..676a383c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_update_flow_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_UpdateFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + flow = dialogflowcx_v3beta1.Flow() + flow.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateFlowRequest( + flow=flow, + ) + + # Make the request + response = client.update_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_UpdateFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_async.py new file mode 100644 index 00000000..ce47053c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ValidateFlow_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = await client.validate_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ValidateFlow_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_sync.py new file mode 100644 index 00000000..fe4611be --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_flows_validate_flow_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ValidateFlow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Flows_ValidateFlow_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_validate_flow(): + # Create a client + client = dialogflowcx_v3beta1.FlowsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ValidateFlowRequest( + name="name_value", + ) + + # Make the request + response = client.validate_flow(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Flows_ValidateFlow_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_async.py new file mode 100644 index 00000000..2c6c9d5c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_CreateIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsAsyncClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = await client.create_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Intents_CreateIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_sync.py new file mode 100644 index 00000000..1d57487e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_create_intent_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_CreateIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateIntentRequest( + parent="parent_value", + intent=intent, + ) + + # Make the request + response = client.create_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Intents_CreateIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_async.py new file mode 100644 index 00000000..394f8e02 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_DeleteIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + await client.delete_intent(request=request) + + +# [END dialogflow_v3beta1_generated_Intents_DeleteIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_sync.py new file mode 100644 index 00000000..743781ed --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_delete_intent_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_DeleteIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteIntentRequest( + name="name_value", + ) + + # Make the request + client.delete_intent(request=request) + + +# [END dialogflow_v3beta1_generated_Intents_DeleteIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_async.py new file mode 100644 index 00000000..91fac11f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_GetIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = await client.get_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Intents_GetIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_sync.py new file mode 100644 index 00000000..75364269 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_get_intent_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_GetIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetIntentRequest( + name="name_value", + ) + + # Make the request + response = client.get_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Intents_GetIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_async.py new file mode 100644 index 00000000..9db8bf09 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIntents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_ListIntents_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_intents(): + # Create a client + client = dialogflowcx_v3beta1.IntentsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Intents_ListIntents_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_sync.py new file mode 100644 index 00000000..0753110a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_list_intents_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListIntents +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_ListIntents_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_intents(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListIntentsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_intents(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Intents_ListIntents_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_async.py new file mode 100644 index 00000000..cb2a58b9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_UpdateIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsAsyncClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = await client.update_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Intents_UpdateIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_sync.py new file mode 100644 index 00000000..aa8127c7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_intents_update_intent_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Intents_UpdateIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_intent(): + # Create a client + client = dialogflowcx_v3beta1.IntentsClient() + + # Initialize request argument(s) + intent = dialogflowcx_v3beta1.Intent() + intent.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateIntentRequest( + intent=intent, + ) + + # Make the request + response = client.update_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Intents_UpdateIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_async.py new file mode 100644 index 00000000..19752af6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_CreatePage_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesAsyncClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = await client.create_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Pages_CreatePage_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_sync.py new file mode 100644 index 00000000..66cf57d8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_create_page_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_CreatePage_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreatePageRequest( + parent="parent_value", + page=page, + ) + + # Make the request + response = client.create_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Pages_CreatePage_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_async.py new file mode 100644 index 00000000..2170a75e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_DeletePage_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeletePageRequest( + name="name_value", + ) + + # Make the request + await client.delete_page(request=request) + + +# [END dialogflow_v3beta1_generated_Pages_DeletePage_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_sync.py new file mode 100644 index 00000000..d42be3a3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_delete_page_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeletePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_DeletePage_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeletePageRequest( + name="name_value", + ) + + # Make the request + client.delete_page(request=request) + + +# [END dialogflow_v3beta1_generated_Pages_DeletePage_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_async.py new file mode 100644 index 00000000..15b206af --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_GetPage_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetPageRequest( + name="name_value", + ) + + # Make the request + response = await client.get_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Pages_GetPage_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_sync.py new file mode 100644 index 00000000..c637ae3c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_get_page_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetPage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_GetPage_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetPageRequest( + name="name_value", + ) + + # Make the request + response = client.get_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Pages_GetPage_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_async.py new file mode 100644 index 00000000..f430971d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_ListPages_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_pages(): + # Create a client + client = dialogflowcx_v3beta1.PagesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Pages_ListPages_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_sync.py new file mode 100644 index 00000000..59f8597e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_list_pages_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListPages +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_ListPages_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_pages(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListPagesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_pages(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Pages_ListPages_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_async.py new file mode 100644 index 00000000..fea5a84e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_UpdatePage_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesAsyncClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdatePageRequest( + page=page, + ) + + # Make the request + response = await client.update_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Pages_UpdatePage_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_sync.py new file mode 100644 index 00000000..1a1f52a7 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_pages_update_page_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdatePage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Pages_UpdatePage_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_page(): + # Create a client + client = dialogflowcx_v3beta1.PagesClient() + + # Initialize request argument(s) + page = dialogflowcx_v3beta1.Page() + page.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdatePageRequest( + page=page, + ) + + # Make the request + response = client.update_page(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Pages_UpdatePage_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_async.py new file mode 100644 index 00000000..c12354f5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_CreateSecuritySettings_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = await client.create_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_CreateSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_sync.py new file mode 100644 index 00000000..4fd778be --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_create_security_settings_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_CreateSecuritySettings_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateSecuritySettingsRequest( + parent="parent_value", + security_settings=security_settings, + ) + + # Make the request + response = client.create_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_CreateSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_async.py new file mode 100644 index 00000000..aafda811 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_DeleteSecuritySettings_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + await client.delete_security_settings(request=request) + + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_DeleteSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_sync.py new file mode 100644 index 00000000..170917f3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_DeleteSecuritySettings_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + client.delete_security_settings(request=request) + + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_DeleteSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_async.py new file mode 100644 index 00000000..721346ee --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_GetSecuritySettings_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = await client.get_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_GetSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_sync.py new file mode 100644 index 00000000..df5d0128 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_get_security_settings_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_GetSecuritySettings_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSecuritySettingsRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_GetSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_async.py new file mode 100644 index 00000000..847f40f1 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_ListSecuritySettings_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_ListSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_sync.py new file mode 100644 index 00000000..52ccbd4b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_list_security_settings_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_ListSecuritySettings_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSecuritySettingsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_settings(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_ListSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_async.py new file mode 100644 index 00000000..c3adec7b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_UpdateSecuritySettings_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceAsyncClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = await client.update_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_UpdateSecuritySettings_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_sync.py new file mode 100644 index 00000000..adba09d4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_security_settings_service_update_security_settings_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSecuritySettings +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SecuritySettingsService_UpdateSecuritySettings_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_security_settings(): + # Create a client + client = dialogflowcx_v3beta1.SecuritySettingsServiceClient() + + # Initialize request argument(s) + security_settings = dialogflowcx_v3beta1.SecuritySettings() + security_settings.retention_window_days = 2271 + security_settings.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateSecuritySettingsRequest( + security_settings=security_settings, + ) + + # Make the request + response = client.update_security_settings(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SecuritySettingsService_UpdateSecuritySettings_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_async.py new file mode 100644 index 00000000..326cb875 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_CreateSessionEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = await client.create_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_CreateSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_sync.py new file mode 100644 index 00000000..4222a7b2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_CreateSessionEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.CreateSessionEntityTypeRequest( + parent="parent_value", + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.create_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_CreateSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_async.py new file mode 100644 index 00000000..8fdc6456 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_DeleteSessionEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + await client.delete_session_entity_type(request=request) + + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_DeleteSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_sync.py new file mode 100644 index 00000000..eec25bff --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_DeleteSessionEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + client.delete_session_entity_type(request=request) + + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_DeleteSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_async.py new file mode 100644 index 00000000..f8bd09b3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_GetSessionEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = await client.get_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_GetSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_sync.py new file mode 100644 index 00000000..142111aa --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_GetSessionEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetSessionEntityTypeRequest( + name="name_value", + ) + + # Make the request + response = client.get_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_GetSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_async.py new file mode 100644 index 00000000..be5184be --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSessionEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_ListSessionEntityTypes_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_ListSessionEntityTypes_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_sync.py new file mode 100644 index 00000000..d6e1874a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSessionEntityTypes +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_ListSessionEntityTypes_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_session_entity_types(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListSessionEntityTypesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_session_entity_types(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_ListSessionEntityTypes_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_async.py new file mode 100644 index 00000000..d74b95c5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_UpdateSessionEntityType_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesAsyncClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = await client.update_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_UpdateSessionEntityType_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_sync.py new file mode 100644 index 00000000..ee7c2c08 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSessionEntityType +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_SessionEntityTypes_UpdateSessionEntityType_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_session_entity_type(): + # Create a client + client = dialogflowcx_v3beta1.SessionEntityTypesClient() + + # Initialize request argument(s) + session_entity_type = dialogflowcx_v3beta1.SessionEntityType() + session_entity_type.name = "name_value" + session_entity_type.entity_override_mode = "ENTITY_OVERRIDE_MODE_SUPPLEMENT" + session_entity_type.entities.value = "value_value" + session_entity_type.entities.synonyms = ['synonyms_value_1', 'synonyms_value_2'] + + request = dialogflowcx_v3beta1.UpdateSessionEntityTypeRequest( + session_entity_type=session_entity_type, + ) + + # Make the request + response = client.update_session_entity_type(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_SessionEntityTypes_UpdateSessionEntityType_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_async.py new file mode 100644 index 00000000..41483a72 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_DetectIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsAsyncClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = await client.detect_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_DetectIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_sync.py new file mode 100644 index 00000000..81ac0881 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_detect_intent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_DetectIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.DetectIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.detect_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_DetectIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_async.py new file mode 100644 index 00000000..c694970d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FulfillIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_FulfillIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.FulfillIntentRequest( + ) + + # Make the request + response = await client.fulfill_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_FulfillIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_sync.py new file mode 100644 index 00000000..d7cace16 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_fulfill_intent_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for FulfillIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_FulfillIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_fulfill_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.FulfillIntentRequest( + ) + + # Make the request + response = client.fulfill_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_FulfillIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_async.py new file mode 100644 index 00000000..2d3f3e8b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for MatchIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_MatchIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_match_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsAsyncClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = await client.match_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_MatchIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_sync.py new file mode 100644 index 00000000..5ad600cb --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_match_intent_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for MatchIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_MatchIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_match_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.MatchIntentRequest( + session="session_value", + query_input=query_input, + ) + + # Make the request + response = client.match_intent(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_MatchIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_async.py new file mode 100644 index 00000000..cdbafe0b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StreamingDetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_StreamingDetectIntent_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsAsyncClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3beta1.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = await client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + async for response in stream: + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_StreamingDetectIntent_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_sync.py new file mode 100644 index 00000000..1db76e2a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_sessions_streaming_detect_intent_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for StreamingDetectIntent +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Sessions_StreamingDetectIntent_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_streaming_detect_intent(): + # Create a client + client = dialogflowcx_v3beta1.SessionsClient() + + # Initialize request argument(s) + query_input = dialogflowcx_v3beta1.QueryInput() + query_input.text.text = "text_value" + query_input.language_code = "language_code_value" + + request = dialogflowcx_v3beta1.StreamingDetectIntentRequest( + query_input=query_input, + ) + + # This method expects an iterator which contains + # 'dialogflowcx_v3beta1.StreamingDetectIntentRequest' objects + # Here we create a generator that yields a single `request` for + # demonstrative purposes. + requests = [request] + + def request_generator(): + for request in requests: + yield request + + # Make the request + stream = client.streaming_detect_intent(requests=request_generator()) + + # Handle the response + for response in stream: + print(response) + +# [END dialogflow_v3beta1_generated_Sessions_StreamingDetectIntent_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_async.py new file mode 100644 index 00000000..26304635 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_BatchDeleteTestCases_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + await client.batch_delete_test_cases(request=request) + + +# [END dialogflow_v3beta1_generated_TestCases_BatchDeleteTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_sync.py new file mode 100644 index 00000000..60978797 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_BatchDeleteTestCases_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_batch_delete_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchDeleteTestCasesRequest( + parent="parent_value", + names=['names_value_1', 'names_value_2'], + ) + + # Make the request + client.batch_delete_test_cases(request=request) + + +# [END dialogflow_v3beta1_generated_TestCases_BatchDeleteTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_async.py new file mode 100644 index 00000000..ed5ea904 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchRunTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_BatchRunTestCases_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_BatchRunTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_sync.py new file mode 100644 index 00000000..63eacf8d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchRunTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_BatchRunTestCases_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_batch_run_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.BatchRunTestCasesRequest( + parent="parent_value", + test_cases=['test_cases_value_1', 'test_cases_value_2'], + ) + + # Make the request + operation = client.batch_run_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_BatchRunTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_async.py new file mode 100644 index 00000000..902d9074 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateCoverage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_CalculateCoverage_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = await client.calculate_coverage(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_CalculateCoverage_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_sync.py new file mode 100644 index 00000000..0e6c8cea --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_calculate_coverage_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CalculateCoverage +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_CalculateCoverage_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_calculate_coverage(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CalculateCoverageRequest( + agent="agent_value", + type_="TRANSITION_ROUTE_GROUP", + ) + + # Make the request + response = client.calculate_coverage(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_CalculateCoverage_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_async.py new file mode 100644 index 00000000..eb1e93bc --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_CreateTestCase_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = await client.create_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_CreateTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_sync.py new file mode 100644 index 00000000..5f0f5959 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_create_test_case_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_CreateTestCase_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTestCaseRequest( + parent="parent_value", + test_case=test_case, + ) + + # Make the request + response = client.create_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_CreateTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_async.py new file mode 100644 index 00000000..9c889948 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ExportTestCases_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ExportTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_sync.py new file mode 100644 index 00000000..9327216b --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_export_test_cases_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ExportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ExportTestCases_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_export_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ExportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.export_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ExportTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_async.py new file mode 100644 index 00000000..4393a667 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_GetTestCase_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = await client.get_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_GetTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_async.py new file mode 100644 index 00000000..e7858261 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCaseResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_GetTestCaseResult_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = await client.get_test_case_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_GetTestCaseResult_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_sync.py new file mode 100644 index 00000000..27f7128d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_result_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCaseResult +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_GetTestCaseResult_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_test_case_result(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseResultRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case_result(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_GetTestCaseResult_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_sync.py new file mode 100644 index 00000000..721e0347 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_get_test_case_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_GetTestCase_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTestCaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_GetTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_async.py new file mode 100644 index 00000000..15ec671f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ImportTestCases_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ImportTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_sync.py new file mode 100644 index 00000000..66e4815c --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_import_test_cases_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ImportTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ImportTestCases_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_import_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ImportTestCasesRequest( + gcs_uri="gcs_uri_value", + parent="parent_value", + ) + + # Make the request + operation = client.import_test_cases(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ImportTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_async.py new file mode 100644 index 00000000..d8f5a3f9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCaseResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ListTestCaseResults_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ListTestCaseResults_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_sync.py new file mode 100644 index 00000000..51b80ef5 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_case_results_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCaseResults +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ListTestCaseResults_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_test_case_results(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCaseResultsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_case_results(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ListTestCaseResults_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_async.py new file mode 100644 index 00000000..64ccb457 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ListTestCases_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ListTestCases_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_sync.py new file mode 100644 index 00000000..5a854417 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_list_test_cases_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTestCases +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_ListTestCases_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_test_cases(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTestCasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_test_cases(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_ListTestCases_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_async.py new file mode 100644 index 00000000..f7bd4082 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_RunTestCase_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_RunTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_sync.py new file mode 100644 index 00000000..a2a558a4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_run_test_case_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_RunTestCase_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_run_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.RunTestCaseRequest( + name="name_value", + ) + + # Make the request + operation = client.run_test_case(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_RunTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_async.py new file mode 100644 index 00000000..62812c8d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_UpdateTestCase_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesAsyncClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = await client.update_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_UpdateTestCase_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_sync.py new file mode 100644 index 00000000..f4e407c2 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_test_cases_update_test_case_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTestCase +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TestCases_UpdateTestCase_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_test_case(): + # Create a client + client = dialogflowcx_v3beta1.TestCasesClient() + + # Initialize request argument(s) + test_case = dialogflowcx_v3beta1.TestCase() + test_case.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTestCaseRequest( + test_case=test_case, + ) + + # Make the request + response = client.update_test_case(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TestCases_UpdateTestCase_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_async.py new file mode 100644 index 00000000..5cc3deb6 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_CreateTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = await client.create_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_CreateTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_sync.py new file mode 100644 index 00000000..2148ebda --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateTransitionRouteGroupRequest( + parent="parent_value", + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.create_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_async.py new file mode 100644 index 00000000..52e92fce --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + await client.delete_transition_route_group(request=request) + + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_sync.py new file mode 100644 index 00000000..2f61446f --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + client.delete_transition_route_group(request=request) + + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_async.py new file mode 100644 index 00000000..b0d556ca --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_GetTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = await client.get_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_GetTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_sync.py new file mode 100644 index 00000000..591b29ff --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetTransitionRouteGroupRequest( + name="name_value", + ) + + # Make the request + response = client.get_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_async.py new file mode 100644 index 00000000..f7bff153 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTransitionRouteGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_ListTransitionRouteGroups_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_ListTransitionRouteGroups_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_sync.py new file mode 100644 index 00000000..827587c8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTransitionRouteGroups +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_transition_route_groups(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListTransitionRouteGroupsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_transition_route_groups(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_async.py new file mode 100644 index 00000000..57bc2a2e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsAsyncClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = await client.update_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_sync.py new file mode 100644 index 00000000..6e7c2046 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTransitionRouteGroup +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_transition_route_group(): + # Create a client + client = dialogflowcx_v3beta1.TransitionRouteGroupsClient() + + # Initialize request argument(s) + transition_route_group = dialogflowcx_v3beta1.TransitionRouteGroup() + transition_route_group.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateTransitionRouteGroupRequest( + transition_route_group=transition_route_group, + ) + + # Make the request + response = client.update_transition_route_group(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_async.py new file mode 100644 index 00000000..4efd2937 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CompareVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_CompareVersions_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = await client.compare_versions(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_CompareVersions_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_sync.py new file mode 100644 index 00000000..1ea09cf4 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_compare_versions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CompareVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_CompareVersions_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_compare_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.CompareVersionsRequest( + base_version="base_version_value", + target_version="target_version_value", + ) + + # Make the request + response = client.compare_versions(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_CompareVersions_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_async.py new file mode 100644 index 00000000..f18f4f87 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_CreateVersion_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_CreateVersion_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_sync.py new file mode 100644 index 00000000..0fc15253 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_create_version_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_CreateVersion_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateVersionRequest( + parent="parent_value", + version=version, + ) + + # Make the request + operation = client.create_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_CreateVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_async.py new file mode 100644 index 00000000..a2728409 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_DeleteVersion_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + await client.delete_version(request=request) + + +# [END dialogflow_v3beta1_generated_Versions_DeleteVersion_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_sync.py new file mode 100644 index 00000000..b3d4e319 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_delete_version_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_DeleteVersion_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteVersionRequest( + name="name_value", + ) + + # Make the request + client.delete_version(request=request) + + +# [END dialogflow_v3beta1_generated_Versions_DeleteVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_async.py new file mode 100644 index 00000000..57ef9ea9 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_GetVersion_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_GetVersion_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_sync.py new file mode 100644 index 00000000..fc917a32 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_get_version_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_GetVersion_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetVersionRequest( + name="name_value", + ) + + # Make the request + response = client.get_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_GetVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_async.py new file mode 100644 index 00000000..8dfe6a32 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_ListVersions_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Versions_ListVersions_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_sync.py new file mode 100644 index 00000000..61a7be21 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_list_versions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_ListVersions_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_versions(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListVersionsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_versions(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Versions_ListVersions_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_async.py new file mode 100644 index 00000000..4b47276a --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LoadVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_LoadVersion_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_load_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_LoadVersion_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_sync.py new file mode 100644 index 00000000..acd313a3 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_load_version_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LoadVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_LoadVersion_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_load_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.LoadVersionRequest( + name="name_value", + ) + + # Make the request + operation = client.load_version(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_LoadVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_async.py new file mode 100644 index 00000000..9f4a0e84 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_UpdateVersion_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsAsyncClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = await client.update_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_UpdateVersion_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_sync.py new file mode 100644 index 00000000..754beb9d --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_versions_update_version_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVersion +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Versions_UpdateVersion_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_version(): + # Create a client + client = dialogflowcx_v3beta1.VersionsClient() + + # Initialize request argument(s) + version = dialogflowcx_v3beta1.Version() + version.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateVersionRequest( + version=version, + ) + + # Make the request + response = client.update_version(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Versions_UpdateVersion_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_async.py new file mode 100644 index 00000000..6cc54b0e --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_CreateWebhook_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksAsyncClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = await client.create_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_CreateWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_sync.py new file mode 100644 index 00000000..39b8ddd8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_create_webhook_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_CreateWebhook_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_create_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.CreateWebhookRequest( + parent="parent_value", + webhook=webhook, + ) + + # Make the request + response = client.create_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_CreateWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_async.py new file mode 100644 index 00000000..6d289930 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_DeleteWebhook_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + await client.delete_webhook(request=request) + + +# [END dialogflow_v3beta1_generated_Webhooks_DeleteWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_sync.py new file mode 100644 index 00000000..451ec5cd --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_delete_webhook_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_DeleteWebhook_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_delete_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.DeleteWebhookRequest( + name="name_value", + ) + + # Make the request + client.delete_webhook(request=request) + + +# [END dialogflow_v3beta1_generated_Webhooks_DeleteWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_async.py new file mode 100644 index 00000000..e4233641 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_GetWebhook_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = await client.get_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_GetWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_sync.py new file mode 100644 index 00000000..e16ea4e8 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_get_webhook_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_GetWebhook_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_get_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.GetWebhookRequest( + name="name_value", + ) + + # Make the request + response = client.get_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_GetWebhook_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_async.py new file mode 100644 index 00000000..78be6f39 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListWebhooks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_ListWebhooks_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksAsyncClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_ListWebhooks_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_sync.py new file mode 100644 index 00000000..01176b39 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_list_webhooks_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListWebhooks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_ListWebhooks_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_list_webhooks(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + request = dialogflowcx_v3beta1.ListWebhooksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_webhooks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_ListWebhooks_sync] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_async.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_async.py new file mode 100644 index 00000000..78cb4c69 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_UpdateWebhook_async] +from google.cloud import dialogflowcx_v3beta1 + + +async def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksAsyncClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = await client.update_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_UpdateWebhook_async] diff --git a/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_sync.py b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_sync.py new file mode 100644 index 00000000..b1fe1d90 --- /dev/null +++ b/samples/generated_samples/dialogflow_v3beta1_generated_webhooks_update_webhook_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateWebhook +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-dialogflowcx + + +# [START dialogflow_v3beta1_generated_Webhooks_UpdateWebhook_sync] +from google.cloud import dialogflowcx_v3beta1 + + +def sample_update_webhook(): + # Create a client + client = dialogflowcx_v3beta1.WebhooksClient() + + # Initialize request argument(s) + webhook = dialogflowcx_v3beta1.Webhook() + webhook.generic_web_service.uri = "uri_value" + webhook.display_name = "display_name_value" + + request = dialogflowcx_v3beta1.UpdateWebhookRequest( + webhook=webhook, + ) + + # Make the request + response = client.update_webhook(request=request) + + # Handle the response + print(response) + +# [END dialogflow_v3beta1_generated_Webhooks_UpdateWebhook_sync] diff --git a/samples/generated_samples/snippet_metadata_dialogflowcx_v3.json b/samples/generated_samples/snippet_metadata_dialogflowcx_v3.json new file mode 100644 index 00000000..4219b511 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_dialogflowcx_v3.json @@ -0,0 +1,8585 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "CreateAgent" + } + }, + "file": "dialogflow_v3_generated_agents_create_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_CreateAgent_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "CreateAgent" + } + }, + "file": "dialogflow_v3_generated_agents_create_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_CreateAgent_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "DeleteAgent" + } + }, + "file": "dialogflow_v3_generated_agents_delete_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_DeleteAgent_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "DeleteAgent" + } + }, + "file": "dialogflow_v3_generated_agents_delete_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_DeleteAgent_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ExportAgent" + } + }, + "file": "dialogflow_v3_generated_agents_export_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_ExportAgent_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ExportAgent" + } + }, + "file": "dialogflow_v3_generated_agents_export_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_ExportAgent_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgentValidationResult" + } + }, + "file": "dialogflow_v3_generated_agents_get_agent_validation_result_async.py", + "regionTag": "dialogflow_v3_generated_Agents_GetAgentValidationResult_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgentValidationResult" + } + }, + "file": "dialogflow_v3_generated_agents_get_agent_validation_result_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_GetAgentValidationResult_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgent" + } + }, + "file": "dialogflow_v3_generated_agents_get_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_GetAgent_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgent" + } + }, + "file": "dialogflow_v3_generated_agents_get_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_GetAgent_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ListAgents" + } + }, + "file": "dialogflow_v3_generated_agents_list_agents_async.py", + "regionTag": "dialogflow_v3_generated_Agents_ListAgents_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ListAgents" + } + }, + "file": "dialogflow_v3_generated_agents_list_agents_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_ListAgents_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "RestoreAgent" + } + }, + "file": "dialogflow_v3_generated_agents_restore_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_RestoreAgent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "RestoreAgent" + } + }, + "file": "dialogflow_v3_generated_agents_restore_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_RestoreAgent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "UpdateAgent" + } + }, + "file": "dialogflow_v3_generated_agents_update_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_UpdateAgent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "UpdateAgent" + } + }, + "file": "dialogflow_v3_generated_agents_update_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_UpdateAgent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ValidateAgent" + } + }, + "file": "dialogflow_v3_generated_agents_validate_agent_async.py", + "regionTag": "dialogflow_v3_generated_Agents_ValidateAgent_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ValidateAgent" + } + }, + "file": "dialogflow_v3_generated_agents_validate_agent_sync.py", + "regionTag": "dialogflow_v3_generated_Agents_ValidateAgent_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "GetChangelog" + } + }, + "file": "dialogflow_v3_generated_changelogs_get_changelog_async.py", + "regionTag": "dialogflow_v3_generated_Changelogs_GetChangelog_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "GetChangelog" + } + }, + "file": "dialogflow_v3_generated_changelogs_get_changelog_sync.py", + "regionTag": "dialogflow_v3_generated_Changelogs_GetChangelog_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "ListChangelogs" + } + }, + "file": "dialogflow_v3_generated_changelogs_list_changelogs_async.py", + "regionTag": "dialogflow_v3_generated_Changelogs_ListChangelogs_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "ListChangelogs" + } + }, + "file": "dialogflow_v3_generated_changelogs_list_changelogs_sync.py", + "regionTag": "dialogflow_v3_generated_Changelogs_ListChangelogs_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "GetDeployment" + } + }, + "file": "dialogflow_v3_generated_deployments_get_deployment_async.py", + "regionTag": "dialogflow_v3_generated_Deployments_GetDeployment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "GetDeployment" + } + }, + "file": "dialogflow_v3_generated_deployments_get_deployment_sync.py", + "regionTag": "dialogflow_v3_generated_Deployments_GetDeployment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "ListDeployments" + } + }, + "file": "dialogflow_v3_generated_deployments_list_deployments_async.py", + "regionTag": "dialogflow_v3_generated_Deployments_ListDeployments_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "ListDeployments" + } + }, + "file": "dialogflow_v3_generated_deployments_list_deployments_sync.py", + "regionTag": "dialogflow_v3_generated_Deployments_ListDeployments_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "CreateEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_create_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_CreateEntityType_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "CreateEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_create_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_CreateEntityType_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "DeleteEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_delete_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_DeleteEntityType_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "DeleteEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_delete_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_DeleteEntityType_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "GetEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_get_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_GetEntityType_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "GetEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_get_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_GetEntityType_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "ListEntityTypes" + } + }, + "file": "dialogflow_v3_generated_entity_types_list_entity_types_async.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_ListEntityTypes_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "ListEntityTypes" + } + }, + "file": "dialogflow_v3_generated_entity_types_list_entity_types_sync.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_ListEntityTypes_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "UpdateEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_update_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_UpdateEntityType_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "UpdateEntityType" + } + }, + "file": "dialogflow_v3_generated_entity_types_update_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_EntityTypes_UpdateEntityType_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "CreateEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_create_environment_async.py", + "regionTag": "dialogflow_v3_generated_Environments_CreateEnvironment_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "CreateEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_create_environment_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_CreateEnvironment_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeleteEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_delete_environment_async.py", + "regionTag": "dialogflow_v3_generated_Environments_DeleteEnvironment_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeleteEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_delete_environment_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_DeleteEnvironment_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeployFlow" + } + }, + "file": "dialogflow_v3_generated_environments_deploy_flow_async.py", + "regionTag": "dialogflow_v3_generated_Environments_DeployFlow_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeployFlow" + } + }, + "file": "dialogflow_v3_generated_environments_deploy_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_DeployFlow_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "GetEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_get_environment_async.py", + "regionTag": "dialogflow_v3_generated_Environments_GetEnvironment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "GetEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_get_environment_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_GetEnvironment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListContinuousTestResults" + } + }, + "file": "dialogflow_v3_generated_environments_list_continuous_test_results_async.py", + "regionTag": "dialogflow_v3_generated_Environments_ListContinuousTestResults_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListContinuousTestResults" + } + }, + "file": "dialogflow_v3_generated_environments_list_continuous_test_results_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_ListContinuousTestResults_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListEnvironments" + } + }, + "file": "dialogflow_v3_generated_environments_list_environments_async.py", + "regionTag": "dialogflow_v3_generated_Environments_ListEnvironments_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListEnvironments" + } + }, + "file": "dialogflow_v3_generated_environments_list_environments_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_ListEnvironments_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "LookupEnvironmentHistory" + } + }, + "file": "dialogflow_v3_generated_environments_lookup_environment_history_async.py", + "regionTag": "dialogflow_v3_generated_Environments_LookupEnvironmentHistory_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "LookupEnvironmentHistory" + } + }, + "file": "dialogflow_v3_generated_environments_lookup_environment_history_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_LookupEnvironmentHistory_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "RunContinuousTest" + } + }, + "file": "dialogflow_v3_generated_environments_run_continuous_test_async.py", + "regionTag": "dialogflow_v3_generated_Environments_RunContinuousTest_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "RunContinuousTest" + } + }, + "file": "dialogflow_v3_generated_environments_run_continuous_test_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_RunContinuousTest_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "UpdateEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_update_environment_async.py", + "regionTag": "dialogflow_v3_generated_Environments_UpdateEnvironment_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "UpdateEnvironment" + } + }, + "file": "dialogflow_v3_generated_environments_update_environment_sync.py", + "regionTag": "dialogflow_v3_generated_Environments_UpdateEnvironment_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "CreateExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_create_experiment_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_CreateExperiment_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "CreateExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_create_experiment_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_CreateExperiment_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "DeleteExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_delete_experiment_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_DeleteExperiment_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "DeleteExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_delete_experiment_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_DeleteExperiment_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "GetExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_get_experiment_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_GetExperiment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "GetExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_get_experiment_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_GetExperiment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "ListExperiments" + } + }, + "file": "dialogflow_v3_generated_experiments_list_experiments_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_ListExperiments_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "ListExperiments" + } + }, + "file": "dialogflow_v3_generated_experiments_list_experiments_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_ListExperiments_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StartExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_start_experiment_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_StartExperiment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StartExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_start_experiment_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_StartExperiment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StopExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_stop_experiment_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_StopExperiment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StopExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_stop_experiment_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_StopExperiment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "UpdateExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_update_experiment_async.py", + "regionTag": "dialogflow_v3_generated_Experiments_UpdateExperiment_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "UpdateExperiment" + } + }, + "file": "dialogflow_v3_generated_experiments_update_experiment_sync.py", + "regionTag": "dialogflow_v3_generated_Experiments_UpdateExperiment_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "CreateFlow" + } + }, + "file": "dialogflow_v3_generated_flows_create_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_CreateFlow_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "CreateFlow" + } + }, + "file": "dialogflow_v3_generated_flows_create_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_CreateFlow_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "DeleteFlow" + } + }, + "file": "dialogflow_v3_generated_flows_delete_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_DeleteFlow_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "DeleteFlow" + } + }, + "file": "dialogflow_v3_generated_flows_delete_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_DeleteFlow_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ExportFlow" + } + }, + "file": "dialogflow_v3_generated_flows_export_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_ExportFlow_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ExportFlow" + } + }, + "file": "dialogflow_v3_generated_flows_export_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_ExportFlow_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlowValidationResult" + } + }, + "file": "dialogflow_v3_generated_flows_get_flow_validation_result_async.py", + "regionTag": "dialogflow_v3_generated_Flows_GetFlowValidationResult_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlowValidationResult" + } + }, + "file": "dialogflow_v3_generated_flows_get_flow_validation_result_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_GetFlowValidationResult_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlow" + } + }, + "file": "dialogflow_v3_generated_flows_get_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_GetFlow_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlow" + } + }, + "file": "dialogflow_v3_generated_flows_get_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_GetFlow_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ImportFlow" + } + }, + "file": "dialogflow_v3_generated_flows_import_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_ImportFlow_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ImportFlow" + } + }, + "file": "dialogflow_v3_generated_flows_import_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_ImportFlow_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ListFlows" + } + }, + "file": "dialogflow_v3_generated_flows_list_flows_async.py", + "regionTag": "dialogflow_v3_generated_Flows_ListFlows_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ListFlows" + } + }, + "file": "dialogflow_v3_generated_flows_list_flows_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_ListFlows_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "TrainFlow" + } + }, + "file": "dialogflow_v3_generated_flows_train_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_TrainFlow_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "TrainFlow" + } + }, + "file": "dialogflow_v3_generated_flows_train_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_TrainFlow_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "UpdateFlow" + } + }, + "file": "dialogflow_v3_generated_flows_update_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_UpdateFlow_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "UpdateFlow" + } + }, + "file": "dialogflow_v3_generated_flows_update_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_UpdateFlow_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ValidateFlow" + } + }, + "file": "dialogflow_v3_generated_flows_validate_flow_async.py", + "regionTag": "dialogflow_v3_generated_Flows_ValidateFlow_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ValidateFlow" + } + }, + "file": "dialogflow_v3_generated_flows_validate_flow_sync.py", + "regionTag": "dialogflow_v3_generated_Flows_ValidateFlow_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "CreateIntent" + } + }, + "file": "dialogflow_v3_generated_intents_create_intent_async.py", + "regionTag": "dialogflow_v3_generated_Intents_CreateIntent_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "CreateIntent" + } + }, + "file": "dialogflow_v3_generated_intents_create_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Intents_CreateIntent_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "DeleteIntent" + } + }, + "file": "dialogflow_v3_generated_intents_delete_intent_async.py", + "regionTag": "dialogflow_v3_generated_Intents_DeleteIntent_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "DeleteIntent" + } + }, + "file": "dialogflow_v3_generated_intents_delete_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Intents_DeleteIntent_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "GetIntent" + } + }, + "file": "dialogflow_v3_generated_intents_get_intent_async.py", + "regionTag": "dialogflow_v3_generated_Intents_GetIntent_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "GetIntent" + } + }, + "file": "dialogflow_v3_generated_intents_get_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Intents_GetIntent_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "ListIntents" + } + }, + "file": "dialogflow_v3_generated_intents_list_intents_async.py", + "regionTag": "dialogflow_v3_generated_Intents_ListIntents_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "ListIntents" + } + }, + "file": "dialogflow_v3_generated_intents_list_intents_sync.py", + "regionTag": "dialogflow_v3_generated_Intents_ListIntents_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "UpdateIntent" + } + }, + "file": "dialogflow_v3_generated_intents_update_intent_async.py", + "regionTag": "dialogflow_v3_generated_Intents_UpdateIntent_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "UpdateIntent" + } + }, + "file": "dialogflow_v3_generated_intents_update_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Intents_UpdateIntent_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "CreatePage" + } + }, + "file": "dialogflow_v3_generated_pages_create_page_async.py", + "regionTag": "dialogflow_v3_generated_Pages_CreatePage_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "CreatePage" + } + }, + "file": "dialogflow_v3_generated_pages_create_page_sync.py", + "regionTag": "dialogflow_v3_generated_Pages_CreatePage_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "DeletePage" + } + }, + "file": "dialogflow_v3_generated_pages_delete_page_async.py", + "regionTag": "dialogflow_v3_generated_Pages_DeletePage_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "DeletePage" + } + }, + "file": "dialogflow_v3_generated_pages_delete_page_sync.py", + "regionTag": "dialogflow_v3_generated_Pages_DeletePage_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "GetPage" + } + }, + "file": "dialogflow_v3_generated_pages_get_page_async.py", + "regionTag": "dialogflow_v3_generated_Pages_GetPage_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "GetPage" + } + }, + "file": "dialogflow_v3_generated_pages_get_page_sync.py", + "regionTag": "dialogflow_v3_generated_Pages_GetPage_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "ListPages" + } + }, + "file": "dialogflow_v3_generated_pages_list_pages_async.py", + "regionTag": "dialogflow_v3_generated_Pages_ListPages_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "ListPages" + } + }, + "file": "dialogflow_v3_generated_pages_list_pages_sync.py", + "regionTag": "dialogflow_v3_generated_Pages_ListPages_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "UpdatePage" + } + }, + "file": "dialogflow_v3_generated_pages_update_page_async.py", + "regionTag": "dialogflow_v3_generated_Pages_UpdatePage_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "UpdatePage" + } + }, + "file": "dialogflow_v3_generated_pages_update_page_sync.py", + "regionTag": "dialogflow_v3_generated_Pages_UpdatePage_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "CreateSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_create_security_settings_async.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "CreateSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_create_security_settings_sync.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_CreateSecuritySettings_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "DeleteSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_delete_security_settings_async.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "DeleteSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_delete_security_settings_sync.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_DeleteSecuritySettings_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "GetSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_get_security_settings_async.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "GetSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_get_security_settings_sync.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_GetSecuritySettings_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "ListSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_list_security_settings_async.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "ListSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_list_security_settings_sync.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_ListSecuritySettings_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "UpdateSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_update_security_settings_async.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "UpdateSecuritySettings" + } + }, + "file": "dialogflow_v3_generated_security_settings_service_update_security_settings_sync.py", + "regionTag": "dialogflow_v3_generated_SecuritySettingsService_UpdateSecuritySettings_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "CreateSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_create_session_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "CreateSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_create_session_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_CreateSessionEntityType_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "DeleteSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_delete_session_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "DeleteSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_delete_session_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_DeleteSessionEntityType_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "GetSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_get_session_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "GetSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_get_session_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_GetSessionEntityType_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "ListSessionEntityTypes" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_list_session_entity_types_async.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "ListSessionEntityTypes" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_list_session_entity_types_sync.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_ListSessionEntityTypes_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "UpdateSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_update_session_entity_type_async.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "UpdateSessionEntityType" + } + }, + "file": "dialogflow_v3_generated_session_entity_types_update_session_entity_type_sync.py", + "regionTag": "dialogflow_v3_generated_SessionEntityTypes_UpdateSessionEntityType_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "DetectIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_detect_intent_async.py", + "regionTag": "dialogflow_v3_generated_Sessions_DetectIntent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "DetectIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_detect_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Sessions_DetectIntent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "FulfillIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_fulfill_intent_async.py", + "regionTag": "dialogflow_v3_generated_Sessions_FulfillIntent_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "FulfillIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_fulfill_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Sessions_FulfillIntent_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "MatchIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_match_intent_async.py", + "regionTag": "dialogflow_v3_generated_Sessions_MatchIntent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "MatchIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_match_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Sessions_MatchIntent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "StreamingDetectIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_streaming_detect_intent_async.py", + "regionTag": "dialogflow_v3_generated_Sessions_StreamingDetectIntent_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "StreamingDetectIntent" + } + }, + "file": "dialogflow_v3_generated_sessions_streaming_detect_intent_sync.py", + "regionTag": "dialogflow_v3_generated_Sessions_StreamingDetectIntent_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchDeleteTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_batch_delete_test_cases_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_BatchDeleteTestCases_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchDeleteTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_batch_delete_test_cases_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_BatchDeleteTestCases_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchRunTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_batch_run_test_cases_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_BatchRunTestCases_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchRunTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_batch_run_test_cases_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_BatchRunTestCases_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CalculateCoverage" + } + }, + "file": "dialogflow_v3_generated_test_cases_calculate_coverage_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_CalculateCoverage_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CalculateCoverage" + } + }, + "file": "dialogflow_v3_generated_test_cases_calculate_coverage_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_CalculateCoverage_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CreateTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_create_test_case_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_CreateTestCase_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CreateTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_create_test_case_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_CreateTestCase_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ExportTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_export_test_cases_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_ExportTestCases_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ExportTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_export_test_cases_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_ExportTestCases_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCaseResult" + } + }, + "file": "dialogflow_v3_generated_test_cases_get_test_case_result_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_GetTestCaseResult_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCaseResult" + } + }, + "file": "dialogflow_v3_generated_test_cases_get_test_case_result_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_GetTestCaseResult_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_get_test_case_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_GetTestCase_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_get_test_case_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_GetTestCase_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ImportTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_import_test_cases_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_ImportTestCases_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ImportTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_import_test_cases_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_ImportTestCases_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCaseResults" + } + }, + "file": "dialogflow_v3_generated_test_cases_list_test_case_results_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_ListTestCaseResults_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCaseResults" + } + }, + "file": "dialogflow_v3_generated_test_cases_list_test_case_results_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_ListTestCaseResults_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_list_test_cases_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_ListTestCases_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCases" + } + }, + "file": "dialogflow_v3_generated_test_cases_list_test_cases_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_ListTestCases_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "RunTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_run_test_case_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_RunTestCase_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "RunTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_run_test_case_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_RunTestCase_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "UpdateTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_update_test_case_async.py", + "regionTag": "dialogflow_v3_generated_TestCases_UpdateTestCase_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "UpdateTestCase" + } + }, + "file": "dialogflow_v3_generated_test_cases_update_test_case_sync.py", + "regionTag": "dialogflow_v3_generated_TestCases_UpdateTestCase_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "CreateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_create_transition_route_group_async.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "CreateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_create_transition_route_group_sync.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "DeleteTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_async.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "DeleteTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_delete_transition_route_group_sync.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "GetTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_get_transition_route_group_async.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "GetTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_get_transition_route_group_sync.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "ListTransitionRouteGroups" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_async.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "ListTransitionRouteGroups" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_list_transition_route_groups_sync.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "UpdateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_update_transition_route_group_async.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "UpdateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3_generated_transition_route_groups_update_transition_route_group_sync.py", + "regionTag": "dialogflow_v3_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CompareVersions" + } + }, + "file": "dialogflow_v3_generated_versions_compare_versions_async.py", + "regionTag": "dialogflow_v3_generated_Versions_CompareVersions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CompareVersions" + } + }, + "file": "dialogflow_v3_generated_versions_compare_versions_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_CompareVersions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CreateVersion" + } + }, + "file": "dialogflow_v3_generated_versions_create_version_async.py", + "regionTag": "dialogflow_v3_generated_Versions_CreateVersion_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CreateVersion" + } + }, + "file": "dialogflow_v3_generated_versions_create_version_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_CreateVersion_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "DeleteVersion" + } + }, + "file": "dialogflow_v3_generated_versions_delete_version_async.py", + "regionTag": "dialogflow_v3_generated_Versions_DeleteVersion_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "DeleteVersion" + } + }, + "file": "dialogflow_v3_generated_versions_delete_version_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_DeleteVersion_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "GetVersion" + } + }, + "file": "dialogflow_v3_generated_versions_get_version_async.py", + "regionTag": "dialogflow_v3_generated_Versions_GetVersion_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "GetVersion" + } + }, + "file": "dialogflow_v3_generated_versions_get_version_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_GetVersion_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "ListVersions" + } + }, + "file": "dialogflow_v3_generated_versions_list_versions_async.py", + "regionTag": "dialogflow_v3_generated_Versions_ListVersions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "ListVersions" + } + }, + "file": "dialogflow_v3_generated_versions_list_versions_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_ListVersions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "LoadVersion" + } + }, + "file": "dialogflow_v3_generated_versions_load_version_async.py", + "regionTag": "dialogflow_v3_generated_Versions_LoadVersion_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "LoadVersion" + } + }, + "file": "dialogflow_v3_generated_versions_load_version_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_LoadVersion_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "UpdateVersion" + } + }, + "file": "dialogflow_v3_generated_versions_update_version_async.py", + "regionTag": "dialogflow_v3_generated_Versions_UpdateVersion_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "UpdateVersion" + } + }, + "file": "dialogflow_v3_generated_versions_update_version_sync.py", + "regionTag": "dialogflow_v3_generated_Versions_UpdateVersion_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "CreateWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_create_webhook_async.py", + "regionTag": "dialogflow_v3_generated_Webhooks_CreateWebhook_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "CreateWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_create_webhook_sync.py", + "regionTag": "dialogflow_v3_generated_Webhooks_CreateWebhook_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "DeleteWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_delete_webhook_async.py", + "regionTag": "dialogflow_v3_generated_Webhooks_DeleteWebhook_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "DeleteWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_delete_webhook_sync.py", + "regionTag": "dialogflow_v3_generated_Webhooks_DeleteWebhook_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "GetWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_get_webhook_async.py", + "regionTag": "dialogflow_v3_generated_Webhooks_GetWebhook_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "GetWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_get_webhook_sync.py", + "regionTag": "dialogflow_v3_generated_Webhooks_GetWebhook_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "ListWebhooks" + } + }, + "file": "dialogflow_v3_generated_webhooks_list_webhooks_async.py", + "regionTag": "dialogflow_v3_generated_Webhooks_ListWebhooks_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "ListWebhooks" + } + }, + "file": "dialogflow_v3_generated_webhooks_list_webhooks_sync.py", + "regionTag": "dialogflow_v3_generated_Webhooks_ListWebhooks_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "UpdateWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_update_webhook_async.py", + "regionTag": "dialogflow_v3_generated_Webhooks_UpdateWebhook_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "UpdateWebhook" + } + }, + "file": "dialogflow_v3_generated_webhooks_update_webhook_sync.py", + "regionTag": "dialogflow_v3_generated_Webhooks_UpdateWebhook_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_dialogflowcx_v3beta1.json b/samples/generated_samples/snippet_metadata_dialogflowcx_v3beta1.json new file mode 100644 index 00000000..7a70c416 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_dialogflowcx_v3beta1.json @@ -0,0 +1,8585 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "CreateAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_create_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_CreateAgent_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "CreateAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_create_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_CreateAgent_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "DeleteAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_delete_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_DeleteAgent_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "DeleteAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_delete_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_DeleteAgent_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ExportAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_export_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_ExportAgent_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ExportAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_export_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_ExportAgent_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgentValidationResult" + } + }, + "file": "dialogflow_v3beta1_generated_agents_get_agent_validation_result_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_GetAgentValidationResult_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgentValidationResult" + } + }, + "file": "dialogflow_v3beta1_generated_agents_get_agent_validation_result_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_GetAgentValidationResult_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_get_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_GetAgent_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "GetAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_get_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_GetAgent_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ListAgents" + } + }, + "file": "dialogflow_v3beta1_generated_agents_list_agents_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_ListAgents_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ListAgents" + } + }, + "file": "dialogflow_v3beta1_generated_agents_list_agents_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_ListAgents_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "RestoreAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_restore_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_RestoreAgent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "RestoreAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_restore_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_RestoreAgent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "UpdateAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_update_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_UpdateAgent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "UpdateAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_update_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_UpdateAgent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ValidateAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_validate_agent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_ValidateAgent_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Agents" + }, + "shortName": "ValidateAgent" + } + }, + "file": "dialogflow_v3beta1_generated_agents_validate_agent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Agents_ValidateAgent_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "GetChangelog" + } + }, + "file": "dialogflow_v3beta1_generated_changelogs_get_changelog_async.py", + "regionTag": "dialogflow_v3beta1_generated_Changelogs_GetChangelog_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "GetChangelog" + } + }, + "file": "dialogflow_v3beta1_generated_changelogs_get_changelog_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Changelogs_GetChangelog_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "ListChangelogs" + } + }, + "file": "dialogflow_v3beta1_generated_changelogs_list_changelogs_async.py", + "regionTag": "dialogflow_v3beta1_generated_Changelogs_ListChangelogs_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Changelogs" + }, + "shortName": "ListChangelogs" + } + }, + "file": "dialogflow_v3beta1_generated_changelogs_list_changelogs_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Changelogs_ListChangelogs_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "GetDeployment" + } + }, + "file": "dialogflow_v3beta1_generated_deployments_get_deployment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Deployments_GetDeployment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "GetDeployment" + } + }, + "file": "dialogflow_v3beta1_generated_deployments_get_deployment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Deployments_GetDeployment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "ListDeployments" + } + }, + "file": "dialogflow_v3beta1_generated_deployments_list_deployments_async.py", + "regionTag": "dialogflow_v3beta1_generated_Deployments_ListDeployments_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Deployments" + }, + "shortName": "ListDeployments" + } + }, + "file": "dialogflow_v3beta1_generated_deployments_list_deployments_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Deployments_ListDeployments_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "CreateEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_create_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_CreateEntityType_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "CreateEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_create_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_CreateEntityType_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "DeleteEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_delete_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_DeleteEntityType_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "DeleteEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_delete_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_DeleteEntityType_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "GetEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_get_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_GetEntityType_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "GetEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_get_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_GetEntityType_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "ListEntityTypes" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_list_entity_types_async.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_ListEntityTypes_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "ListEntityTypes" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_list_entity_types_sync.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_ListEntityTypes_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "UpdateEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_update_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_UpdateEntityType_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "EntityTypes" + }, + "shortName": "UpdateEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_entity_types_update_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_EntityTypes_UpdateEntityType_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "CreateEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_create_environment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_CreateEnvironment_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "CreateEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_create_environment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_CreateEnvironment_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeleteEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_delete_environment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_DeleteEnvironment_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeleteEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_delete_environment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_DeleteEnvironment_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeployFlow" + } + }, + "file": "dialogflow_v3beta1_generated_environments_deploy_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_DeployFlow_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "DeployFlow" + } + }, + "file": "dialogflow_v3beta1_generated_environments_deploy_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_DeployFlow_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "GetEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_get_environment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_GetEnvironment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "GetEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_get_environment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_GetEnvironment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListContinuousTestResults" + } + }, + "file": "dialogflow_v3beta1_generated_environments_list_continuous_test_results_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_ListContinuousTestResults_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListContinuousTestResults" + } + }, + "file": "dialogflow_v3beta1_generated_environments_list_continuous_test_results_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_ListContinuousTestResults_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListEnvironments" + } + }, + "file": "dialogflow_v3beta1_generated_environments_list_environments_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_ListEnvironments_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "ListEnvironments" + } + }, + "file": "dialogflow_v3beta1_generated_environments_list_environments_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_ListEnvironments_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "LookupEnvironmentHistory" + } + }, + "file": "dialogflow_v3beta1_generated_environments_lookup_environment_history_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_LookupEnvironmentHistory_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "LookupEnvironmentHistory" + } + }, + "file": "dialogflow_v3beta1_generated_environments_lookup_environment_history_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_LookupEnvironmentHistory_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "RunContinuousTest" + } + }, + "file": "dialogflow_v3beta1_generated_environments_run_continuous_test_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_RunContinuousTest_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "RunContinuousTest" + } + }, + "file": "dialogflow_v3beta1_generated_environments_run_continuous_test_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_RunContinuousTest_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "UpdateEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_update_environment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_UpdateEnvironment_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Environments" + }, + "shortName": "UpdateEnvironment" + } + }, + "file": "dialogflow_v3beta1_generated_environments_update_environment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Environments_UpdateEnvironment_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "CreateExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_create_experiment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_CreateExperiment_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "CreateExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_create_experiment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_CreateExperiment_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "DeleteExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_delete_experiment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_DeleteExperiment_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "DeleteExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_delete_experiment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_DeleteExperiment_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "GetExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_get_experiment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_GetExperiment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "GetExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_get_experiment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_GetExperiment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "ListExperiments" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_list_experiments_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_ListExperiments_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "ListExperiments" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_list_experiments_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_ListExperiments_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StartExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_start_experiment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_StartExperiment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StartExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_start_experiment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_StartExperiment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StopExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_stop_experiment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_StopExperiment_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "StopExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_stop_experiment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_StopExperiment_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "UpdateExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_update_experiment_async.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_UpdateExperiment_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Experiments" + }, + "shortName": "UpdateExperiment" + } + }, + "file": "dialogflow_v3beta1_generated_experiments_update_experiment_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Experiments_UpdateExperiment_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "CreateFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_create_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_CreateFlow_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "CreateFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_create_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_CreateFlow_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "DeleteFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_delete_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_DeleteFlow_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "DeleteFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_delete_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_DeleteFlow_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ExportFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_export_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ExportFlow_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ExportFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_export_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ExportFlow_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlowValidationResult" + } + }, + "file": "dialogflow_v3beta1_generated_flows_get_flow_validation_result_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_GetFlowValidationResult_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlowValidationResult" + } + }, + "file": "dialogflow_v3beta1_generated_flows_get_flow_validation_result_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_GetFlowValidationResult_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_get_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_GetFlow_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "GetFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_get_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_GetFlow_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ImportFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_import_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ImportFlow_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ImportFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_import_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ImportFlow_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ListFlows" + } + }, + "file": "dialogflow_v3beta1_generated_flows_list_flows_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ListFlows_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ListFlows" + } + }, + "file": "dialogflow_v3beta1_generated_flows_list_flows_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ListFlows_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "TrainFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_train_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_TrainFlow_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "TrainFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_train_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_TrainFlow_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "UpdateFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_update_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_UpdateFlow_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "UpdateFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_update_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_UpdateFlow_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ValidateFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_validate_flow_async.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ValidateFlow_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Flows" + }, + "shortName": "ValidateFlow" + } + }, + "file": "dialogflow_v3beta1_generated_flows_validate_flow_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Flows_ValidateFlow_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "CreateIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_create_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_CreateIntent_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "CreateIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_create_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_CreateIntent_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "DeleteIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_delete_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_DeleteIntent_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "DeleteIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_delete_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_DeleteIntent_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "GetIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_get_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_GetIntent_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "GetIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_get_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_GetIntent_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "ListIntents" + } + }, + "file": "dialogflow_v3beta1_generated_intents_list_intents_async.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_ListIntents_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "ListIntents" + } + }, + "file": "dialogflow_v3beta1_generated_intents_list_intents_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_ListIntents_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "UpdateIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_update_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_UpdateIntent_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Intents" + }, + "shortName": "UpdateIntent" + } + }, + "file": "dialogflow_v3beta1_generated_intents_update_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Intents_UpdateIntent_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "CreatePage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_create_page_async.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_CreatePage_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "CreatePage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_create_page_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_CreatePage_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "DeletePage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_delete_page_async.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_DeletePage_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "DeletePage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_delete_page_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_DeletePage_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "GetPage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_get_page_async.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_GetPage_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "GetPage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_get_page_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_GetPage_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "ListPages" + } + }, + "file": "dialogflow_v3beta1_generated_pages_list_pages_async.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_ListPages_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "ListPages" + } + }, + "file": "dialogflow_v3beta1_generated_pages_list_pages_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_ListPages_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "UpdatePage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_update_page_async.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_UpdatePage_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Pages" + }, + "shortName": "UpdatePage" + } + }, + "file": "dialogflow_v3beta1_generated_pages_update_page_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Pages_UpdatePage_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "CreateSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_create_security_settings_async.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_CreateSecuritySettings_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "CreateSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_create_security_settings_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_CreateSecuritySettings_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "DeleteSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_async.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_DeleteSecuritySettings_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "DeleteSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_delete_security_settings_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_DeleteSecuritySettings_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "GetSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_get_security_settings_async.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_GetSecuritySettings_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "GetSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_get_security_settings_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_GetSecuritySettings_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "ListSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_list_security_settings_async.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_ListSecuritySettings_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "ListSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_list_security_settings_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_ListSecuritySettings_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "UpdateSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_update_security_settings_async.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_UpdateSecuritySettings_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SecuritySettingsService" + }, + "shortName": "UpdateSecuritySettings" + } + }, + "file": "dialogflow_v3beta1_generated_security_settings_service_update_security_settings_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SecuritySettingsService_UpdateSecuritySettings_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "CreateSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_CreateSessionEntityType_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "CreateSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_create_session_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_CreateSessionEntityType_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "DeleteSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_DeleteSessionEntityType_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "DeleteSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_delete_session_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_DeleteSessionEntityType_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "GetSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_GetSessionEntityType_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "GetSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_get_session_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_GetSessionEntityType_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "ListSessionEntityTypes" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_async.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_ListSessionEntityTypes_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "ListSessionEntityTypes" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_list_session_entity_types_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_ListSessionEntityTypes_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "UpdateSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_async.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_UpdateSessionEntityType_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "SessionEntityTypes" + }, + "shortName": "UpdateSessionEntityType" + } + }, + "file": "dialogflow_v3beta1_generated_session_entity_types_update_session_entity_type_sync.py", + "regionTag": "dialogflow_v3beta1_generated_SessionEntityTypes_UpdateSessionEntityType_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "DetectIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_detect_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_DetectIntent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "DetectIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_detect_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_DetectIntent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "FulfillIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_fulfill_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_FulfillIntent_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "FulfillIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_fulfill_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_FulfillIntent_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "MatchIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_match_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_MatchIntent_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "MatchIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_match_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_MatchIntent_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "StreamingDetectIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_streaming_detect_intent_async.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_StreamingDetectIntent_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Sessions" + }, + "shortName": "StreamingDetectIntent" + } + }, + "file": "dialogflow_v3beta1_generated_sessions_streaming_detect_intent_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Sessions_StreamingDetectIntent_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 52, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 55, + "start": 53, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 56, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchDeleteTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_BatchDeleteTestCases_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchDeleteTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_batch_delete_test_cases_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_BatchDeleteTestCases_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchRunTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_BatchRunTestCases_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "BatchRunTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_batch_run_test_cases_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_BatchRunTestCases_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CalculateCoverage" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_calculate_coverage_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_CalculateCoverage_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CalculateCoverage" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_calculate_coverage_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_CalculateCoverage_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CreateTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_create_test_case_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_CreateTestCase_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "CreateTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_create_test_case_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_CreateTestCase_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ExportTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_export_test_cases_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ExportTestCases_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ExportTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_export_test_cases_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ExportTestCases_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCaseResult" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_get_test_case_result_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_GetTestCaseResult_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCaseResult" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_get_test_case_result_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_GetTestCaseResult_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_get_test_case_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_GetTestCase_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "GetTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_get_test_case_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_GetTestCase_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ImportTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_import_test_cases_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ImportTestCases_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ImportTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_import_test_cases_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ImportTestCases_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCaseResults" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_list_test_case_results_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ListTestCaseResults_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCaseResults" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_list_test_case_results_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ListTestCaseResults_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_list_test_cases_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ListTestCases_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "ListTestCases" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_list_test_cases_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_ListTestCases_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "RunTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_run_test_case_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_RunTestCase_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "RunTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_run_test_case_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_RunTestCase_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "UpdateTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_update_test_case_async.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_UpdateTestCase_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TestCases" + }, + "shortName": "UpdateTestCase" + } + }, + "file": "dialogflow_v3beta1_generated_test_cases_update_test_case_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TestCases_UpdateTestCase_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "CreateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_async.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_CreateTransitionRouteGroup_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "CreateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_create_transition_route_group_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_CreateTransitionRouteGroup_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "DeleteTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_async.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "DeleteTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_delete_transition_route_group_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_DeleteTransitionRouteGroup_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "GetTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_async.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_GetTransitionRouteGroup_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "GetTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_get_transition_route_group_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_GetTransitionRouteGroup_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "ListTransitionRouteGroups" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_async.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_ListTransitionRouteGroups_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "ListTransitionRouteGroups" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_list_transition_route_groups_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_ListTransitionRouteGroups_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "UpdateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_async.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "TransitionRouteGroups" + }, + "shortName": "UpdateTransitionRouteGroup" + } + }, + "file": "dialogflow_v3beta1_generated_transition_route_groups_update_transition_route_group_sync.py", + "regionTag": "dialogflow_v3beta1_generated_TransitionRouteGroups_UpdateTransitionRouteGroup_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CompareVersions" + } + }, + "file": "dialogflow_v3beta1_generated_versions_compare_versions_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_CompareVersions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CompareVersions" + } + }, + "file": "dialogflow_v3beta1_generated_versions_compare_versions_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_CompareVersions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CreateVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_create_version_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_CreateVersion_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "CreateVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_create_version_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_CreateVersion_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 49, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 50, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "DeleteVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_delete_version_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_DeleteVersion_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "DeleteVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_delete_version_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_DeleteVersion_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "GetVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_get_version_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_GetVersion_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "GetVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_get_version_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_GetVersion_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "ListVersions" + } + }, + "file": "dialogflow_v3beta1_generated_versions_list_versions_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_ListVersions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "ListVersions" + } + }, + "file": "dialogflow_v3beta1_generated_versions_list_versions_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_ListVersions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "LoadVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_load_version_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_LoadVersion_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "LoadVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_load_version_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_LoadVersion_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "UpdateVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_update_version_async.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_UpdateVersion_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Versions" + }, + "shortName": "UpdateVersion" + } + }, + "file": "dialogflow_v3beta1_generated_versions_update_version_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Versions_UpdateVersion_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 41, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 42, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "CreateWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_create_webhook_async.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_CreateWebhook_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "CreateWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_create_webhook_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_CreateWebhook_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "DeleteWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_delete_webhook_async.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_DeleteWebhook_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "DeleteWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_delete_webhook_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_DeleteWebhook_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "GetWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_get_webhook_async.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_GetWebhook_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "GetWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_get_webhook_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_GetWebhook_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "ListWebhooks" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_list_webhooks_async.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_ListWebhooks_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "ListWebhooks" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_list_webhooks_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_ListWebhooks_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "UpdateWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_update_webhook_async.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_UpdateWebhook_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "Webhooks" + }, + "shortName": "UpdateWebhook" + } + }, + "file": "dialogflow_v3beta1_generated_webhooks_update_webhook_sync.py", + "regionTag": "dialogflow_v3beta1_generated_Webhooks_UpdateWebhook_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 42, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 43, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/snippets/create_agent.py b/samples/snippets/create_agent.py index 8b116812..daff5ff6 100644 --- a/samples/snippets/create_agent.py +++ b/samples/snippets/create_agent.py @@ -35,4 +35,6 @@ def create_agent(project_id, display_name): response = agents_client.create_agent(request={"agent": agent, "parent": parent}) return response + + ## [END dialogflow_cx_create_agent_sample] diff --git a/samples/snippets/detect_intent_stream.py b/samples/snippets/detect_intent_stream.py index ebe71515..38824646 100644 --- a/samples/snippets/detect_intent_stream.py +++ b/samples/snippets/detect_intent_stream.py @@ -79,17 +79,23 @@ def request_generator(): # Sets the voice name and gender voice_selection.name = "en-GB-Standard-A" - voice_selection.ssml_gender = audio_config.SsmlVoiceGender.SSML_VOICE_GENDER_FEMALE + voice_selection.ssml_gender = ( + audio_config.SsmlVoiceGender.SSML_VOICE_GENDER_FEMALE + ) synthesize_speech_config.voice = voice_selection # Sets the audio encoding - output_audio_config.audio_encoding = audio_config.OutputAudioEncoding.OUTPUT_AUDIO_ENCODING_UNSPECIFIED + output_audio_config.audio_encoding = ( + audio_config.OutputAudioEncoding.OUTPUT_AUDIO_ENCODING_UNSPECIFIED + ) output_audio_config.synthesize_speech_config = synthesize_speech_config # The first request contains the configuration. yield session.StreamingDetectIntentRequest( - session=session_path, query_input=query_input, output_audio_config=output_audio_config + session=session_path, + query_input=query_input, + output_audio_config=output_audio_config, ) # Here we are reading small chunks of audio data from a local diff --git a/samples/snippets/long_running_operation.py b/samples/snippets/long_running_operation.py index 0eb540c8..7dea2543 100644 --- a/samples/snippets/long_running_operation.py +++ b/samples/snippets/long_running_operation.py @@ -22,18 +22,22 @@ def export_long_running_agent(project_id, agent_id, location): - api_endpoint = f'{location}-dialogflow.googleapis.com:443' + api_endpoint = f"{location}-dialogflow.googleapis.com:443" client_options = {"api_endpoint": api_endpoint} agents_client = AgentsClient(client_options=client_options) export_request = ExportAgentRequest() - export_request.name = f'projects/{project_id}/locations/{location}/agents/{agent_id}' + export_request.name = ( + f"projects/{project_id}/locations/{location}/agents/{agent_id}" + ) # export_agent returns a long running operation operation = agents_client.export_agent(request=export_request) # Returns the result of the operation when the operation is done return operation.result() + + ## [END dialogflow_cx_long_running_snippet] diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 92709451..c2845bff 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==6.2.5 +pytest==7.0.1 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 7feead52..f239b496 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-dialogflow-cx==1.7.0 -Flask==2.0.2 +google-cloud-dialogflow-cx==1.8.0 +Flask==2.0.3 diff --git a/samples/snippets/update_intent.py b/samples/snippets/update_intent.py index 9ba552a4..ba7f5588 100644 --- a/samples/snippets/update_intent.py +++ b/samples/snippets/update_intent.py @@ -28,4 +28,6 @@ def update_intent(project_id, agent_id, intent_id, location, displayName): update_mask = field_mask_pb2.FieldMask(paths=["display_name"]) response = intents_client.update_intent(intent=intent, update_mask=update_mask) return response + + # [END dialogflow_cx_update_intent] diff --git a/samples/snippets/webhook.py b/samples/snippets/webhook.py index 143f11ee..09871847 100644 --- a/samples/snippets/webhook.py +++ b/samples/snippets/webhook.py @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -''' handle_webhook will return the correct fullfilment response dependong the tag that is sent in the request''' +""" handle_webhook will return the correct fullfilment response dependong the tag that is sent in the request""" # [START dialogflow_cx_webhook] @@ -56,4 +56,5 @@ def handle_webhook(request): # Returns json return res + # [END dialogflow_cx_webhook] diff --git a/samples/snippets/webhook_test.py b/samples/snippets/webhook_test.py index dee58ddf..fd91a17b 100644 --- a/samples/snippets/webhook_test.py +++ b/samples/snippets/webhook_test.py @@ -20,12 +20,10 @@ # Create a fake 'app' for generating test request contexts. -request = { - "fulfillmentInfo": {"tag": "Default Welcome Intent"} -} +request = {"fulfillmentInfo": {"tag": "Default Welcome Intent"}} -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def app(): return flask.Flask(__name__) @@ -33,4 +31,4 @@ def app(): def test_handle_webhook(app): with app.test_request_context(json=request): res = handle_webhook(flask.request) - assert 'Hi from a GCF Webhook' in str(res) + assert "Hi from a GCF Webhook" in str(res) diff --git a/scripts/fixup_dialogflowcx_v3_keywords.py b/scripts/fixup_dialogflowcx_v3_keywords.py new file mode 100644 index 00000000..87532407 --- /dev/null +++ b/scripts/fixup_dialogflowcx_v3_keywords.py @@ -0,0 +1,272 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class dialogflowcxCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'batch_delete_test_cases': ('parent', 'names', ), + 'batch_run_test_cases': ('parent', 'test_cases', 'environment', ), + 'calculate_coverage': ('agent', 'type_', ), + 'compare_versions': ('base_version', 'target_version', 'language_code', ), + 'create_agent': ('parent', 'agent', ), + 'create_entity_type': ('parent', 'entity_type', 'language_code', ), + 'create_environment': ('parent', 'environment', ), + 'create_experiment': ('parent', 'experiment', ), + 'create_flow': ('parent', 'flow', 'language_code', ), + 'create_intent': ('parent', 'intent', 'language_code', ), + 'create_page': ('parent', 'page', 'language_code', ), + 'create_security_settings': ('parent', 'security_settings', ), + 'create_session_entity_type': ('parent', 'session_entity_type', ), + 'create_test_case': ('parent', 'test_case', ), + 'create_transition_route_group': ('parent', 'transition_route_group', 'language_code', ), + 'create_version': ('parent', 'version', ), + 'create_webhook': ('parent', 'webhook', ), + 'delete_agent': ('name', ), + 'delete_entity_type': ('name', 'force', ), + 'delete_environment': ('name', ), + 'delete_experiment': ('name', ), + 'delete_flow': ('name', 'force', ), + 'delete_intent': ('name', ), + 'delete_page': ('name', 'force', ), + 'delete_security_settings': ('name', ), + 'delete_session_entity_type': ('name', ), + 'delete_transition_route_group': ('name', 'force', ), + 'delete_version': ('name', ), + 'delete_webhook': ('name', 'force', ), + 'deploy_flow': ('environment', 'flow_version', ), + 'detect_intent': ('session', 'query_input', 'query_params', 'output_audio_config', ), + 'export_agent': ('name', 'agent_uri', 'environment', ), + 'export_flow': ('name', 'flow_uri', 'include_referenced_flows', ), + 'export_test_cases': ('parent', 'gcs_uri', 'data_format', 'filter', ), + 'fulfill_intent': ('match_intent_request', 'match', 'output_audio_config', ), + 'get_agent': ('name', ), + 'get_agent_validation_result': ('name', 'language_code', ), + 'get_changelog': ('name', ), + 'get_deployment': ('name', ), + 'get_entity_type': ('name', 'language_code', ), + 'get_environment': ('name', ), + 'get_experiment': ('name', ), + 'get_flow': ('name', 'language_code', ), + 'get_flow_validation_result': ('name', 'language_code', ), + 'get_intent': ('name', 'language_code', ), + 'get_page': ('name', 'language_code', ), + 'get_security_settings': ('name', ), + 'get_session_entity_type': ('name', ), + 'get_test_case': ('name', ), + 'get_test_case_result': ('name', ), + 'get_transition_route_group': ('name', 'language_code', ), + 'get_version': ('name', ), + 'get_webhook': ('name', ), + 'import_flow': ('parent', 'flow_uri', 'flow_content', 'import_option', ), + 'import_test_cases': ('parent', 'gcs_uri', 'content', ), + 'list_agents': ('parent', 'page_size', 'page_token', ), + 'list_changelogs': ('parent', 'filter', 'page_size', 'page_token', ), + 'list_continuous_test_results': ('parent', 'page_size', 'page_token', ), + 'list_deployments': ('parent', 'page_size', 'page_token', ), + 'list_entity_types': ('parent', 'language_code', 'page_size', 'page_token', ), + 'list_environments': ('parent', 'page_size', 'page_token', ), + 'list_experiments': ('parent', 'page_size', 'page_token', ), + 'list_flows': ('parent', 'page_size', 'page_token', 'language_code', ), + 'list_intents': ('parent', 'language_code', 'intent_view', 'page_size', 'page_token', ), + 'list_pages': ('parent', 'language_code', 'page_size', 'page_token', ), + 'list_security_settings': ('parent', 'page_size', 'page_token', ), + 'list_session_entity_types': ('parent', 'page_size', 'page_token', ), + 'list_test_case_results': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_test_cases': ('parent', 'page_size', 'page_token', 'view', ), + 'list_transition_route_groups': ('parent', 'page_size', 'page_token', 'language_code', ), + 'list_versions': ('parent', 'page_size', 'page_token', ), + 'list_webhooks': ('parent', 'page_size', 'page_token', ), + 'load_version': ('name', 'allow_override_agent_resources', ), + 'lookup_environment_history': ('name', 'page_size', 'page_token', ), + 'match_intent': ('session', 'query_input', 'query_params', ), + 'restore_agent': ('name', 'agent_uri', 'agent_content', 'restore_option', ), + 'run_continuous_test': ('environment', ), + 'run_test_case': ('name', 'environment', ), + 'start_experiment': ('name', ), + 'stop_experiment': ('name', ), + 'streaming_detect_intent': ('query_input', 'session', 'query_params', 'output_audio_config', 'enable_partial_response', ), + 'train_flow': ('name', ), + 'update_agent': ('agent', 'update_mask', ), + 'update_entity_type': ('entity_type', 'language_code', 'update_mask', ), + 'update_environment': ('environment', 'update_mask', ), + 'update_experiment': ('experiment', 'update_mask', ), + 'update_flow': ('flow', 'update_mask', 'language_code', ), + 'update_intent': ('intent', 'language_code', 'update_mask', ), + 'update_page': ('page', 'language_code', 'update_mask', ), + 'update_security_settings': ('security_settings', 'update_mask', ), + 'update_session_entity_type': ('session_entity_type', 'update_mask', ), + 'update_test_case': ('test_case', 'update_mask', ), + 'update_transition_route_group': ('transition_route_group', 'update_mask', 'language_code', ), + 'update_version': ('version', 'update_mask', ), + 'update_webhook': ('webhook', 'update_mask', ), + 'validate_agent': ('name', 'language_code', ), + 'validate_flow': ('name', 'language_code', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=dialogflowcxCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the dialogflowcx client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/scripts/fixup_dialogflowcx_v3beta1_keywords.py b/scripts/fixup_dialogflowcx_v3beta1_keywords.py new file mode 100644 index 00000000..87532407 --- /dev/null +++ b/scripts/fixup_dialogflowcx_v3beta1_keywords.py @@ -0,0 +1,272 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class dialogflowcxCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'batch_delete_test_cases': ('parent', 'names', ), + 'batch_run_test_cases': ('parent', 'test_cases', 'environment', ), + 'calculate_coverage': ('agent', 'type_', ), + 'compare_versions': ('base_version', 'target_version', 'language_code', ), + 'create_agent': ('parent', 'agent', ), + 'create_entity_type': ('parent', 'entity_type', 'language_code', ), + 'create_environment': ('parent', 'environment', ), + 'create_experiment': ('parent', 'experiment', ), + 'create_flow': ('parent', 'flow', 'language_code', ), + 'create_intent': ('parent', 'intent', 'language_code', ), + 'create_page': ('parent', 'page', 'language_code', ), + 'create_security_settings': ('parent', 'security_settings', ), + 'create_session_entity_type': ('parent', 'session_entity_type', ), + 'create_test_case': ('parent', 'test_case', ), + 'create_transition_route_group': ('parent', 'transition_route_group', 'language_code', ), + 'create_version': ('parent', 'version', ), + 'create_webhook': ('parent', 'webhook', ), + 'delete_agent': ('name', ), + 'delete_entity_type': ('name', 'force', ), + 'delete_environment': ('name', ), + 'delete_experiment': ('name', ), + 'delete_flow': ('name', 'force', ), + 'delete_intent': ('name', ), + 'delete_page': ('name', 'force', ), + 'delete_security_settings': ('name', ), + 'delete_session_entity_type': ('name', ), + 'delete_transition_route_group': ('name', 'force', ), + 'delete_version': ('name', ), + 'delete_webhook': ('name', 'force', ), + 'deploy_flow': ('environment', 'flow_version', ), + 'detect_intent': ('session', 'query_input', 'query_params', 'output_audio_config', ), + 'export_agent': ('name', 'agent_uri', 'environment', ), + 'export_flow': ('name', 'flow_uri', 'include_referenced_flows', ), + 'export_test_cases': ('parent', 'gcs_uri', 'data_format', 'filter', ), + 'fulfill_intent': ('match_intent_request', 'match', 'output_audio_config', ), + 'get_agent': ('name', ), + 'get_agent_validation_result': ('name', 'language_code', ), + 'get_changelog': ('name', ), + 'get_deployment': ('name', ), + 'get_entity_type': ('name', 'language_code', ), + 'get_environment': ('name', ), + 'get_experiment': ('name', ), + 'get_flow': ('name', 'language_code', ), + 'get_flow_validation_result': ('name', 'language_code', ), + 'get_intent': ('name', 'language_code', ), + 'get_page': ('name', 'language_code', ), + 'get_security_settings': ('name', ), + 'get_session_entity_type': ('name', ), + 'get_test_case': ('name', ), + 'get_test_case_result': ('name', ), + 'get_transition_route_group': ('name', 'language_code', ), + 'get_version': ('name', ), + 'get_webhook': ('name', ), + 'import_flow': ('parent', 'flow_uri', 'flow_content', 'import_option', ), + 'import_test_cases': ('parent', 'gcs_uri', 'content', ), + 'list_agents': ('parent', 'page_size', 'page_token', ), + 'list_changelogs': ('parent', 'filter', 'page_size', 'page_token', ), + 'list_continuous_test_results': ('parent', 'page_size', 'page_token', ), + 'list_deployments': ('parent', 'page_size', 'page_token', ), + 'list_entity_types': ('parent', 'language_code', 'page_size', 'page_token', ), + 'list_environments': ('parent', 'page_size', 'page_token', ), + 'list_experiments': ('parent', 'page_size', 'page_token', ), + 'list_flows': ('parent', 'page_size', 'page_token', 'language_code', ), + 'list_intents': ('parent', 'language_code', 'intent_view', 'page_size', 'page_token', ), + 'list_pages': ('parent', 'language_code', 'page_size', 'page_token', ), + 'list_security_settings': ('parent', 'page_size', 'page_token', ), + 'list_session_entity_types': ('parent', 'page_size', 'page_token', ), + 'list_test_case_results': ('parent', 'page_size', 'page_token', 'filter', ), + 'list_test_cases': ('parent', 'page_size', 'page_token', 'view', ), + 'list_transition_route_groups': ('parent', 'page_size', 'page_token', 'language_code', ), + 'list_versions': ('parent', 'page_size', 'page_token', ), + 'list_webhooks': ('parent', 'page_size', 'page_token', ), + 'load_version': ('name', 'allow_override_agent_resources', ), + 'lookup_environment_history': ('name', 'page_size', 'page_token', ), + 'match_intent': ('session', 'query_input', 'query_params', ), + 'restore_agent': ('name', 'agent_uri', 'agent_content', 'restore_option', ), + 'run_continuous_test': ('environment', ), + 'run_test_case': ('name', 'environment', ), + 'start_experiment': ('name', ), + 'stop_experiment': ('name', ), + 'streaming_detect_intent': ('query_input', 'session', 'query_params', 'output_audio_config', 'enable_partial_response', ), + 'train_flow': ('name', ), + 'update_agent': ('agent', 'update_mask', ), + 'update_entity_type': ('entity_type', 'language_code', 'update_mask', ), + 'update_environment': ('environment', 'update_mask', ), + 'update_experiment': ('experiment', 'update_mask', ), + 'update_flow': ('flow', 'update_mask', 'language_code', ), + 'update_intent': ('intent', 'language_code', 'update_mask', ), + 'update_page': ('page', 'language_code', 'update_mask', ), + 'update_security_settings': ('security_settings', 'update_mask', ), + 'update_session_entity_type': ('session_entity_type', 'update_mask', ), + 'update_test_case': ('test_case', 'update_mask', ), + 'update_transition_route_group': ('transition_route_group', 'update_mask', 'language_code', ), + 'update_version': ('version', 'update_mask', ), + 'update_webhook': ('webhook', 'update_mask', ), + 'validate_agent': ('name', 'language_code', ), + 'validate_flow': ('name', 'language_code', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=dialogflowcxCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the dialogflowcx client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/setup.py b/setup.py index cd7b751a..9a6d8756 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import os import setuptools # type: ignore -version = "1.8.0" +version = "1.9.0" package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/tests/__init__.py b/tests/__init__.py index 4de65971..e8e1c384 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 4de65971..e8e1c384 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py index 4de65971..e8e1c384 100644 --- a/tests/unit/gapic/__init__.py +++ b/tests/unit/gapic/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/dialogflowcx_v3/__init__.py b/tests/unit/gapic/dialogflowcx_v3/__init__.py index 4de65971..e8e1c384 100644 --- a/tests/unit/gapic/dialogflowcx_v3/__init__.py +++ b/tests/unit/gapic/dialogflowcx_v3/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/dialogflowcx_v3/test_agents.py b/tests/unit/gapic/dialogflowcx_v3/test_agents.py index 90cddf5a..d6d26853 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_agents.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_agents.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -378,6 +379,81 @@ def test_agents_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [AgentsClient, AgentsAsyncClient]) +@mock.patch.object( + AgentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AgentsClient) +) +@mock.patch.object( + AgentsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AgentsAsyncClient) +) +def test_agents_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -406,17 +482,23 @@ def test_agents_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (AgentsClient, transports.AgentsGrpcTransport, "grpc"), - (AgentsAsyncClient, transports.AgentsGrpcAsyncIOTransport, "grpc_asyncio"), + (AgentsClient, transports.AgentsGrpcTransport, "grpc", grpc_helpers), + ( + AgentsAsyncClient, + transports.AgentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_agents_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -450,6 +532,70 @@ def test_agents_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (AgentsClient, transports.AgentsGrpcTransport, "grpc", grpc_helpers), + ( + AgentsAsyncClient, + transports.AgentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_agents_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [agent.ListAgentsRequest, dict,]) def test_list_agents(request_type, transport: str = "grpc"): client = AgentsClient( @@ -2285,6 +2431,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.AgentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AgentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AgentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.AgentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3004,3 +3167,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (AgentsClient, transports.AgentsGrpcTransport), + (AgentsAsyncClient, transports.AgentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_changelogs.py b/tests/unit/gapic/dialogflowcx_v3/test_changelogs.py index ad0cf9d9..34a0adff 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_changelogs.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_changelogs.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -385,6 +385,83 @@ def test_changelogs_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [ChangelogsClient, ChangelogsAsyncClient]) +@mock.patch.object( + ChangelogsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ChangelogsClient) +) +@mock.patch.object( + ChangelogsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(ChangelogsAsyncClient), +) +def test_changelogs_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -417,21 +494,23 @@ def test_changelogs_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (ChangelogsClient, transports.ChangelogsGrpcTransport, "grpc"), + (ChangelogsClient, transports.ChangelogsGrpcTransport, "grpc", grpc_helpers), ( ChangelogsAsyncClient, transports.ChangelogsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_changelogs_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -465,6 +544,70 @@ def test_changelogs_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (ChangelogsClient, transports.ChangelogsGrpcTransport, "grpc", grpc_helpers), + ( + ChangelogsAsyncClient, + transports.ChangelogsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_changelogs_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [changelog.ListChangelogsRequest, dict,]) def test_list_changelogs(request_type, transport: str = "grpc"): client = ChangelogsClient( @@ -1039,6 +1182,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.ChangelogsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ChangelogsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ChangelogsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.ChangelogsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1596,3 +1756,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (ChangelogsClient, transports.ChangelogsGrpcTransport), + (ChangelogsAsyncClient, transports.ChangelogsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_deployments.py b/tests/unit/gapic/dialogflowcx_v3/test_deployments.py index 102eb6d1..cdf0324e 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_deployments.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_deployments.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -385,6 +385,83 @@ def test_deployments_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [DeploymentsClient, DeploymentsAsyncClient]) +@mock.patch.object( + DeploymentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DeploymentsClient) +) +@mock.patch.object( + DeploymentsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(DeploymentsAsyncClient), +) +def test_deployments_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -417,21 +494,23 @@ def test_deployments_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (DeploymentsClient, transports.DeploymentsGrpcTransport, "grpc"), + (DeploymentsClient, transports.DeploymentsGrpcTransport, "grpc", grpc_helpers), ( DeploymentsAsyncClient, transports.DeploymentsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_deployments_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -465,6 +544,70 @@ def test_deployments_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (DeploymentsClient, transports.DeploymentsGrpcTransport, "grpc", grpc_helpers), + ( + DeploymentsAsyncClient, + transports.DeploymentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_deployments_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [deployment.ListDeploymentsRequest, dict,]) def test_list_deployments(request_type, transport: str = "grpc"): client = DeploymentsClient( @@ -1031,6 +1174,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.DeploymentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = DeploymentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = DeploymentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.DeploymentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1692,3 +1852,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (DeploymentsClient, transports.DeploymentsGrpcTransport), + (DeploymentsAsyncClient, transports.DeploymentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py b/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py index 1801f9af..33fb08b2 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_entity_types.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -386,6 +386,83 @@ def test_entity_types_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [EntityTypesClient, EntityTypesAsyncClient]) +@mock.patch.object( + EntityTypesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EntityTypesClient) +) +@mock.patch.object( + EntityTypesAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(EntityTypesAsyncClient), +) +def test_entity_types_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -418,21 +495,23 @@ def test_entity_types_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (EntityTypesClient, transports.EntityTypesGrpcTransport, "grpc"), + (EntityTypesClient, transports.EntityTypesGrpcTransport, "grpc", grpc_helpers), ( EntityTypesAsyncClient, transports.EntityTypesGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_entity_types_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -466,6 +545,70 @@ def test_entity_types_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (EntityTypesClient, transports.EntityTypesGrpcTransport, "grpc", grpc_helpers), + ( + EntityTypesAsyncClient, + transports.EntityTypesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_entity_types_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [entity_type.ListEntityTypesRequest, dict,]) def test_list_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( @@ -1803,6 +1946,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.EntityTypesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EntityTypesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EntityTypesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.EntityTypesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2363,3 +2523,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (EntityTypesClient, transports.EntityTypesGrpcTransport), + (EntityTypesAsyncClient, transports.EntityTypesGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_environments.py b/tests/unit/gapic/dialogflowcx_v3/test_environments.py index 9c90d311..c4f93879 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_environments.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_environments.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -392,6 +393,83 @@ def test_environments_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [EnvironmentsClient, EnvironmentsAsyncClient]) +@mock.patch.object( + EnvironmentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EnvironmentsClient) +) +@mock.patch.object( + EnvironmentsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(EnvironmentsAsyncClient), +) +def test_environments_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -424,21 +502,28 @@ def test_environments_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (EnvironmentsClient, transports.EnvironmentsGrpcTransport, "grpc"), + ( + EnvironmentsClient, + transports.EnvironmentsGrpcTransport, + "grpc", + grpc_helpers, + ), ( EnvironmentsAsyncClient, transports.EnvironmentsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_environments_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -472,6 +557,75 @@ def test_environments_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + EnvironmentsClient, + transports.EnvironmentsGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + EnvironmentsAsyncClient, + transports.EnvironmentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_environments_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [environment.ListEnvironmentsRequest, dict,]) def test_list_environments(request_type, transport: str = "grpc"): client = EnvironmentsClient( @@ -2753,6 +2907,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.EnvironmentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EnvironmentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EnvironmentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.EnvironmentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3476,3 +3647,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (EnvironmentsClient, transports.EnvironmentsGrpcTransport), + (EnvironmentsAsyncClient, transports.EnvironmentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_experiments.py b/tests/unit/gapic/dialogflowcx_v3/test_experiments.py index 6fa46d9e..aa139075 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_experiments.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_experiments.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -388,6 +388,83 @@ def test_experiments_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [ExperimentsClient, ExperimentsAsyncClient]) +@mock.patch.object( + ExperimentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ExperimentsClient) +) +@mock.patch.object( + ExperimentsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(ExperimentsAsyncClient), +) +def test_experiments_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -420,21 +497,23 @@ def test_experiments_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (ExperimentsClient, transports.ExperimentsGrpcTransport, "grpc"), + (ExperimentsClient, transports.ExperimentsGrpcTransport, "grpc", grpc_helpers), ( ExperimentsAsyncClient, transports.ExperimentsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_experiments_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -468,6 +547,70 @@ def test_experiments_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (ExperimentsClient, transports.ExperimentsGrpcTransport, "grpc", grpc_helpers), + ( + ExperimentsAsyncClient, + transports.ExperimentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_experiments_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [experiment.ListExperimentsRequest, dict,]) def test_list_experiments(request_type, transport: str = "grpc"): client = ExperimentsClient( @@ -2173,6 +2316,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.ExperimentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ExperimentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ExperimentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.ExperimentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2771,3 +2931,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (ExperimentsClient, transports.ExperimentsGrpcTransport), + (ExperimentsAsyncClient, transports.ExperimentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_flows.py b/tests/unit/gapic/dialogflowcx_v3/test_flows.py index c3030bc0..d1ebff7e 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_flows.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_flows.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -381,6 +382,81 @@ def test_flows_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [FlowsClient, FlowsAsyncClient]) +@mock.patch.object( + FlowsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FlowsClient) +) +@mock.patch.object( + FlowsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FlowsAsyncClient) +) +def test_flows_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -409,17 +485,23 @@ def test_flows_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (FlowsClient, transports.FlowsGrpcTransport, "grpc"), - (FlowsAsyncClient, transports.FlowsGrpcAsyncIOTransport, "grpc_asyncio"), + (FlowsClient, transports.FlowsGrpcTransport, "grpc", grpc_helpers), + ( + FlowsAsyncClient, + transports.FlowsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_flows_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -453,6 +535,70 @@ def test_flows_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (FlowsClient, transports.FlowsGrpcTransport, "grpc", grpc_helpers), + ( + FlowsAsyncClient, + transports.FlowsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_flows_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [gcdc_flow.CreateFlowRequest, dict,]) def test_create_flow(request_type, transport: str = "grpc"): client = FlowsClient( @@ -2393,6 +2539,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.FlowsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = FlowsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = FlowsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.FlowsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3123,3 +3286,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (FlowsClient, transports.FlowsGrpcTransport), + (FlowsAsyncClient, transports.FlowsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_intents.py b/tests/unit/gapic/dialogflowcx_v3/test_intents.py index ae3076c7..52358b5f 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_intents.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_intents.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -371,6 +371,81 @@ def test_intents_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [IntentsClient, IntentsAsyncClient]) +@mock.patch.object( + IntentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(IntentsClient) +) +@mock.patch.object( + IntentsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(IntentsAsyncClient) +) +def test_intents_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -399,17 +474,23 @@ def test_intents_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (IntentsClient, transports.IntentsGrpcTransport, "grpc"), - (IntentsAsyncClient, transports.IntentsGrpcAsyncIOTransport, "grpc_asyncio"), + (IntentsClient, transports.IntentsGrpcTransport, "grpc", grpc_helpers), + ( + IntentsAsyncClient, + transports.IntentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_intents_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -443,6 +524,70 @@ def test_intents_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (IntentsClient, transports.IntentsGrpcTransport, "grpc", grpc_helpers), + ( + IntentsAsyncClient, + transports.IntentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_intents_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [intent.ListIntentsRequest, dict,]) def test_list_intents(request_type, transport: str = "grpc"): client = IntentsClient( @@ -1628,6 +1773,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.IntentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = IntentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = IntentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.IntentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2214,3 +2376,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (IntentsClient, transports.IntentsGrpcTransport), + (IntentsAsyncClient, transports.IntentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_pages.py b/tests/unit/gapic/dialogflowcx_v3/test_pages.py index d93818cf..0ad0b4a3 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_pages.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_pages.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -374,6 +374,81 @@ def test_pages_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [PagesClient, PagesAsyncClient]) +@mock.patch.object( + PagesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(PagesClient) +) +@mock.patch.object( + PagesAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(PagesAsyncClient) +) +def test_pages_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -402,17 +477,23 @@ def test_pages_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (PagesClient, transports.PagesGrpcTransport, "grpc"), - (PagesAsyncClient, transports.PagesGrpcAsyncIOTransport, "grpc_asyncio"), + (PagesClient, transports.PagesGrpcTransport, "grpc", grpc_helpers), + ( + PagesAsyncClient, + transports.PagesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_pages_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -446,6 +527,70 @@ def test_pages_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (PagesClient, transports.PagesGrpcTransport, "grpc", grpc_helpers), + ( + PagesAsyncClient, + transports.PagesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_pages_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [page.ListPagesRequest, dict,]) def test_list_pages(request_type, transport: str = "grpc"): client = PagesClient( @@ -1595,6 +1740,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.PagesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PagesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PagesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.PagesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2289,3 +2451,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (PagesClient, transports.PagesGrpcTransport), + (PagesAsyncClient, transports.PagesGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) 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 a5466cf7..f0328241 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_security_settings_service.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -418,6 +418,89 @@ def test_security_settings_service_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [SecuritySettingsServiceClient, SecuritySettingsServiceAsyncClient] +) +@mock.patch.object( + SecuritySettingsServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SecuritySettingsServiceClient), +) +@mock.patch.object( + SecuritySettingsServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SecuritySettingsServiceAsyncClient), +) +def test_security_settings_service_client_get_mtls_endpoint_and_cert_source( + client_class, +): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -454,25 +537,28 @@ def test_security_settings_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( SecuritySettingsServiceClient, transports.SecuritySettingsServiceGrpcTransport, "grpc", + grpc_helpers, ), ( SecuritySettingsServiceAsyncClient, transports.SecuritySettingsServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_security_settings_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -508,6 +594,75 @@ def test_security_settings_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + SecuritySettingsServiceClient, + transports.SecuritySettingsServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + SecuritySettingsServiceAsyncClient, + transports.SecuritySettingsServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_security_settings_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [gcdc_security_settings.CreateSecuritySettingsRequest, dict,] ) @@ -2023,6 +2178,25 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SecuritySettingsServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecuritySettingsServiceClient( + client_options=options, transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecuritySettingsServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SecuritySettingsServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2662,3 +2836,39 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + ( + SecuritySettingsServiceClient, + transports.SecuritySettingsServiceGrpcTransport, + ), + ( + SecuritySettingsServiceAsyncClient, + transports.SecuritySettingsServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) 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 6c6ae148..dee340fd 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_session_entity_types.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -415,6 +415,87 @@ def test_session_entity_types_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [SessionEntityTypesClient, SessionEntityTypesAsyncClient] +) +@mock.patch.object( + SessionEntityTypesClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SessionEntityTypesClient), +) +@mock.patch.object( + SessionEntityTypesAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SessionEntityTypesAsyncClient), +) +def test_session_entity_types_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -447,21 +528,28 @@ def test_session_entity_types_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (SessionEntityTypesClient, transports.SessionEntityTypesGrpcTransport, "grpc"), + ( + SessionEntityTypesClient, + transports.SessionEntityTypesGrpcTransport, + "grpc", + grpc_helpers, + ), ( SessionEntityTypesAsyncClient, transports.SessionEntityTypesGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_session_entity_types_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -497,6 +585,75 @@ def test_session_entity_types_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + SessionEntityTypesClient, + transports.SessionEntityTypesGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + SessionEntityTypesAsyncClient, + transports.SessionEntityTypesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_session_entity_types_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [session_entity_type.ListSessionEntityTypesRequest, dict,] ) @@ -1911,6 +2068,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SessionEntityTypesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionEntityTypesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionEntityTypesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SessionEntityTypesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2500,3 +2674,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (SessionEntityTypesClient, transports.SessionEntityTypesGrpcTransport), + ( + SessionEntityTypesAsyncClient, + transports.SessionEntityTypesGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_sessions.py b/tests/unit/gapic/dialogflowcx_v3/test_sessions.py index d5164315..7cd204e5 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_sessions.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_sessions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -382,6 +382,83 @@ def test_sessions_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [SessionsClient, SessionsAsyncClient]) +@mock.patch.object( + SessionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SessionsClient) +) +@mock.patch.object( + SessionsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SessionsAsyncClient), +) +def test_sessions_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -410,17 +487,23 @@ def test_sessions_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (SessionsClient, transports.SessionsGrpcTransport, "grpc"), - (SessionsAsyncClient, transports.SessionsGrpcAsyncIOTransport, "grpc_asyncio"), + (SessionsClient, transports.SessionsGrpcTransport, "grpc", grpc_helpers), + ( + SessionsAsyncClient, + transports.SessionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_sessions_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -454,6 +537,70 @@ def test_sessions_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (SessionsClient, transports.SessionsGrpcTransport, "grpc", grpc_helpers), + ( + SessionsAsyncClient, + transports.SessionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_sessions_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [session.DetectIntentRequest, dict,]) def test_detect_intent(request_type, transport: str = "grpc"): client = SessionsClient( @@ -949,6 +1096,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SessionsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SessionsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1736,3 +1900,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (SessionsClient, transports.SessionsGrpcTransport), + (SessionsAsyncClient, transports.SessionsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py b/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py index 725798b5..701db3d4 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_test_cases.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -398,6 +399,83 @@ def test_test_cases_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [TestCasesClient, TestCasesAsyncClient]) +@mock.patch.object( + TestCasesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TestCasesClient) +) +@mock.patch.object( + TestCasesAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TestCasesAsyncClient), +) +def test_test_cases_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -430,21 +508,23 @@ def test_test_cases_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (TestCasesClient, transports.TestCasesGrpcTransport, "grpc"), + (TestCasesClient, transports.TestCasesGrpcTransport, "grpc", grpc_helpers), ( TestCasesAsyncClient, transports.TestCasesGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_test_cases_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -478,6 +558,70 @@ def test_test_cases_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (TestCasesClient, transports.TestCasesGrpcTransport, "grpc", grpc_helpers), + ( + TestCasesAsyncClient, + transports.TestCasesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_test_cases_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [test_case.ListTestCasesRequest, dict,]) def test_list_test_cases(request_type, transport: str = "grpc"): client = TestCasesClient( @@ -2977,6 +3121,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.TestCasesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TestCasesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TestCasesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.TestCasesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3825,3 +3986,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (TestCasesClient, transports.TestCasesGrpcTransport), + (TestCasesAsyncClient, transports.TestCasesGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) 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 49e61150..28e75e2c 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_transition_route_groups.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -422,6 +422,87 @@ def test_transition_route_groups_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [TransitionRouteGroupsClient, TransitionRouteGroupsAsyncClient] +) +@mock.patch.object( + TransitionRouteGroupsClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TransitionRouteGroupsClient), +) +@mock.patch.object( + TransitionRouteGroupsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TransitionRouteGroupsAsyncClient), +) +def test_transition_route_groups_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -458,25 +539,28 @@ def test_transition_route_groups_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( TransitionRouteGroupsClient, transports.TransitionRouteGroupsGrpcTransport, "grpc", + grpc_helpers, ), ( TransitionRouteGroupsAsyncClient, transports.TransitionRouteGroupsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_transition_route_groups_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -512,6 +596,75 @@ def test_transition_route_groups_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + TransitionRouteGroupsClient, + transports.TransitionRouteGroupsGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + TransitionRouteGroupsAsyncClient, + transports.TransitionRouteGroupsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_transition_route_groups_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [transition_route_group.ListTransitionRouteGroupsRequest, dict,] ) @@ -1931,6 +2084,25 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.TransitionRouteGroupsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TransitionRouteGroupsClient( + client_options=options, transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TransitionRouteGroupsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.TransitionRouteGroupsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2628,3 +2800,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (TransitionRouteGroupsClient, transports.TransitionRouteGroupsGrpcTransport), + ( + TransitionRouteGroupsAsyncClient, + transports.TransitionRouteGroupsGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_versions.py b/tests/unit/gapic/dialogflowcx_v3/test_versions.py index 19722603..8fac0e1c 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_versions.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_versions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -385,6 +386,83 @@ def test_versions_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient]) +@mock.patch.object( + VersionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VersionsClient) +) +@mock.patch.object( + VersionsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(VersionsAsyncClient), +) +def test_versions_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -413,17 +491,23 @@ def test_versions_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (VersionsClient, transports.VersionsGrpcTransport, "grpc"), - (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"), + (VersionsClient, transports.VersionsGrpcTransport, "grpc", grpc_helpers), + ( + VersionsAsyncClient, + transports.VersionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_versions_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -457,6 +541,70 @@ def test_versions_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (VersionsClient, transports.VersionsGrpcTransport, "grpc", grpc_helpers), + ( + VersionsAsyncClient, + transports.VersionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_versions_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [version.ListVersionsRequest, dict,]) def test_list_versions(request_type, transport: str = "grpc"): client = VersionsClient( @@ -2032,6 +2180,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.VersionsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VersionsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VersionsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.VersionsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2627,3 +2792,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (VersionsClient, transports.VersionsGrpcTransport), + (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py b/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py index e9ac905a..4cdbc9e7 100644 --- a/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py +++ b/tests/unit/gapic/dialogflowcx_v3/test_webhooks.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -379,6 +379,83 @@ def test_webhooks_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [WebhooksClient, WebhooksAsyncClient]) +@mock.patch.object( + WebhooksClient, "DEFAULT_ENDPOINT", modify_default_endpoint(WebhooksClient) +) +@mock.patch.object( + WebhooksAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(WebhooksAsyncClient), +) +def test_webhooks_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -407,17 +484,23 @@ def test_webhooks_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (WebhooksClient, transports.WebhooksGrpcTransport, "grpc"), - (WebhooksAsyncClient, transports.WebhooksGrpcAsyncIOTransport, "grpc_asyncio"), + (WebhooksClient, transports.WebhooksGrpcTransport, "grpc", grpc_helpers), + ( + WebhooksAsyncClient, + transports.WebhooksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_webhooks_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -451,6 +534,70 @@ def test_webhooks_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (WebhooksClient, transports.WebhooksGrpcTransport, "grpc", grpc_helpers), + ( + WebhooksAsyncClient, + transports.WebhooksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_webhooks_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [webhook.ListWebhooksRequest, dict,]) def test_list_webhooks(request_type, transport: str = "grpc"): client = WebhooksClient( @@ -1629,6 +1776,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.WebhooksGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = WebhooksClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = WebhooksClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.WebhooksGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2215,3 +2379,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (WebhooksClient, transports.WebhooksGrpcTransport), + (WebhooksAsyncClient, transports.WebhooksGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/__init__.py b/tests/unit/gapic/dialogflowcx_v3beta1/__init__.py index 4de65971..e8e1c384 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/__init__.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py index 69e4fd07..1a4331c5 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_agents.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -378,6 +379,81 @@ def test_agents_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [AgentsClient, AgentsAsyncClient]) +@mock.patch.object( + AgentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AgentsClient) +) +@mock.patch.object( + AgentsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(AgentsAsyncClient) +) +def test_agents_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -406,17 +482,23 @@ def test_agents_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (AgentsClient, transports.AgentsGrpcTransport, "grpc"), - (AgentsAsyncClient, transports.AgentsGrpcAsyncIOTransport, "grpc_asyncio"), + (AgentsClient, transports.AgentsGrpcTransport, "grpc", grpc_helpers), + ( + AgentsAsyncClient, + transports.AgentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_agents_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -450,6 +532,70 @@ def test_agents_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (AgentsClient, transports.AgentsGrpcTransport, "grpc", grpc_helpers), + ( + AgentsAsyncClient, + transports.AgentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_agents_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [agent.ListAgentsRequest, dict,]) def test_list_agents(request_type, transport: str = "grpc"): client = AgentsClient( @@ -2285,6 +2431,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.AgentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AgentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = AgentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.AgentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3004,3 +3167,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (AgentsClient, transports.AgentsGrpcTransport), + (AgentsAsyncClient, transports.AgentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_changelogs.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_changelogs.py index 302f762f..2fd0d217 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_changelogs.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_changelogs.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -385,6 +385,83 @@ def test_changelogs_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [ChangelogsClient, ChangelogsAsyncClient]) +@mock.patch.object( + ChangelogsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ChangelogsClient) +) +@mock.patch.object( + ChangelogsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(ChangelogsAsyncClient), +) +def test_changelogs_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -417,21 +494,23 @@ def test_changelogs_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (ChangelogsClient, transports.ChangelogsGrpcTransport, "grpc"), + (ChangelogsClient, transports.ChangelogsGrpcTransport, "grpc", grpc_helpers), ( ChangelogsAsyncClient, transports.ChangelogsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_changelogs_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -465,6 +544,70 @@ def test_changelogs_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (ChangelogsClient, transports.ChangelogsGrpcTransport, "grpc", grpc_helpers), + ( + ChangelogsAsyncClient, + transports.ChangelogsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_changelogs_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [changelog.ListChangelogsRequest, dict,]) def test_list_changelogs(request_type, transport: str = "grpc"): client = ChangelogsClient( @@ -1039,6 +1182,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.ChangelogsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ChangelogsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ChangelogsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.ChangelogsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1596,3 +1756,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (ChangelogsClient, transports.ChangelogsGrpcTransport), + (ChangelogsAsyncClient, transports.ChangelogsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_deployments.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_deployments.py index c113cee8..75b600dc 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_deployments.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_deployments.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -387,6 +387,83 @@ def test_deployments_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [DeploymentsClient, DeploymentsAsyncClient]) +@mock.patch.object( + DeploymentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(DeploymentsClient) +) +@mock.patch.object( + DeploymentsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(DeploymentsAsyncClient), +) +def test_deployments_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -419,21 +496,23 @@ def test_deployments_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (DeploymentsClient, transports.DeploymentsGrpcTransport, "grpc"), + (DeploymentsClient, transports.DeploymentsGrpcTransport, "grpc", grpc_helpers), ( DeploymentsAsyncClient, transports.DeploymentsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_deployments_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -467,6 +546,70 @@ def test_deployments_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (DeploymentsClient, transports.DeploymentsGrpcTransport, "grpc", grpc_helpers), + ( + DeploymentsAsyncClient, + transports.DeploymentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_deployments_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [deployment.ListDeploymentsRequest, dict,]) def test_list_deployments(request_type, transport: str = "grpc"): client = DeploymentsClient( @@ -1033,6 +1176,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.DeploymentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = DeploymentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = DeploymentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.DeploymentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1694,3 +1854,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (DeploymentsClient, transports.DeploymentsGrpcTransport), + (DeploymentsAsyncClient, transports.DeploymentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py index 8259bee7..66d1db42 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_entity_types.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -388,6 +388,83 @@ def test_entity_types_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [EntityTypesClient, EntityTypesAsyncClient]) +@mock.patch.object( + EntityTypesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EntityTypesClient) +) +@mock.patch.object( + EntityTypesAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(EntityTypesAsyncClient), +) +def test_entity_types_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -420,21 +497,23 @@ def test_entity_types_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (EntityTypesClient, transports.EntityTypesGrpcTransport, "grpc"), + (EntityTypesClient, transports.EntityTypesGrpcTransport, "grpc", grpc_helpers), ( EntityTypesAsyncClient, transports.EntityTypesGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_entity_types_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -468,6 +547,70 @@ def test_entity_types_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (EntityTypesClient, transports.EntityTypesGrpcTransport, "grpc", grpc_helpers), + ( + EntityTypesAsyncClient, + transports.EntityTypesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_entity_types_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [entity_type.ListEntityTypesRequest, dict,]) def test_list_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( @@ -1805,6 +1948,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.EntityTypesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EntityTypesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EntityTypesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.EntityTypesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2365,3 +2525,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (EntityTypesClient, transports.EntityTypesGrpcTransport), + (EntityTypesAsyncClient, transports.EntityTypesGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py index a18627a5..9b229c72 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_environments.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -394,6 +395,83 @@ def test_environments_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [EnvironmentsClient, EnvironmentsAsyncClient]) +@mock.patch.object( + EnvironmentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(EnvironmentsClient) +) +@mock.patch.object( + EnvironmentsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(EnvironmentsAsyncClient), +) +def test_environments_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -426,21 +504,28 @@ def test_environments_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (EnvironmentsClient, transports.EnvironmentsGrpcTransport, "grpc"), + ( + EnvironmentsClient, + transports.EnvironmentsGrpcTransport, + "grpc", + grpc_helpers, + ), ( EnvironmentsAsyncClient, transports.EnvironmentsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_environments_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -474,6 +559,75 @@ def test_environments_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + EnvironmentsClient, + transports.EnvironmentsGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + EnvironmentsAsyncClient, + transports.EnvironmentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_environments_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [environment.ListEnvironmentsRequest, dict,]) def test_list_environments(request_type, transport: str = "grpc"): client = EnvironmentsClient( @@ -2755,6 +2909,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.EnvironmentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EnvironmentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = EnvironmentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.EnvironmentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3478,3 +3649,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (EnvironmentsClient, transports.EnvironmentsGrpcTransport), + (EnvironmentsAsyncClient, transports.EnvironmentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py index 6f65edd3..1079024e 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_experiments.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -390,6 +390,83 @@ def test_experiments_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [ExperimentsClient, ExperimentsAsyncClient]) +@mock.patch.object( + ExperimentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(ExperimentsClient) +) +@mock.patch.object( + ExperimentsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(ExperimentsAsyncClient), +) +def test_experiments_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -422,21 +499,23 @@ def test_experiments_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (ExperimentsClient, transports.ExperimentsGrpcTransport, "grpc"), + (ExperimentsClient, transports.ExperimentsGrpcTransport, "grpc", grpc_helpers), ( ExperimentsAsyncClient, transports.ExperimentsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_experiments_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -470,6 +549,70 @@ def test_experiments_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (ExperimentsClient, transports.ExperimentsGrpcTransport, "grpc", grpc_helpers), + ( + ExperimentsAsyncClient, + transports.ExperimentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_experiments_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [experiment.ListExperimentsRequest, dict,]) def test_list_experiments(request_type, transport: str = "grpc"): client = ExperimentsClient( @@ -2175,6 +2318,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.ExperimentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ExperimentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = ExperimentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.ExperimentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2773,3 +2933,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (ExperimentsClient, transports.ExperimentsGrpcTransport), + (ExperimentsAsyncClient, transports.ExperimentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py index a913be9f..376bd78c 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_flows.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -381,6 +382,81 @@ def test_flows_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [FlowsClient, FlowsAsyncClient]) +@mock.patch.object( + FlowsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FlowsClient) +) +@mock.patch.object( + FlowsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(FlowsAsyncClient) +) +def test_flows_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -409,17 +485,23 @@ def test_flows_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (FlowsClient, transports.FlowsGrpcTransport, "grpc"), - (FlowsAsyncClient, transports.FlowsGrpcAsyncIOTransport, "grpc_asyncio"), + (FlowsClient, transports.FlowsGrpcTransport, "grpc", grpc_helpers), + ( + FlowsAsyncClient, + transports.FlowsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_flows_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -453,6 +535,70 @@ def test_flows_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (FlowsClient, transports.FlowsGrpcTransport, "grpc", grpc_helpers), + ( + FlowsAsyncClient, + transports.FlowsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_flows_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [gcdc_flow.CreateFlowRequest, dict,]) def test_create_flow(request_type, transport: str = "grpc"): client = FlowsClient( @@ -2393,6 +2539,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.FlowsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = FlowsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = FlowsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.FlowsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3123,3 +3286,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (FlowsClient, transports.FlowsGrpcTransport), + (FlowsAsyncClient, transports.FlowsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py index 64f2b6b6..4af3d5e1 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_intents.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -371,6 +371,81 @@ def test_intents_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [IntentsClient, IntentsAsyncClient]) +@mock.patch.object( + IntentsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(IntentsClient) +) +@mock.patch.object( + IntentsAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(IntentsAsyncClient) +) +def test_intents_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -399,17 +474,23 @@ def test_intents_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (IntentsClient, transports.IntentsGrpcTransport, "grpc"), - (IntentsAsyncClient, transports.IntentsGrpcAsyncIOTransport, "grpc_asyncio"), + (IntentsClient, transports.IntentsGrpcTransport, "grpc", grpc_helpers), + ( + IntentsAsyncClient, + transports.IntentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_intents_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -443,6 +524,70 @@ def test_intents_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (IntentsClient, transports.IntentsGrpcTransport, "grpc", grpc_helpers), + ( + IntentsAsyncClient, + transports.IntentsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_intents_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [intent.ListIntentsRequest, dict,]) def test_list_intents(request_type, transport: str = "grpc"): client = IntentsClient( @@ -1628,6 +1773,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.IntentsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = IntentsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = IntentsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.IntentsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2214,3 +2376,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (IntentsClient, transports.IntentsGrpcTransport), + (IntentsAsyncClient, transports.IntentsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py index fe1e0828..dc75a40a 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -374,6 +374,81 @@ def test_pages_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [PagesClient, PagesAsyncClient]) +@mock.patch.object( + PagesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(PagesClient) +) +@mock.patch.object( + PagesAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(PagesAsyncClient) +) +def test_pages_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -402,17 +477,23 @@ def test_pages_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (PagesClient, transports.PagesGrpcTransport, "grpc"), - (PagesAsyncClient, transports.PagesGrpcAsyncIOTransport, "grpc_asyncio"), + (PagesClient, transports.PagesGrpcTransport, "grpc", grpc_helpers), + ( + PagesAsyncClient, + transports.PagesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_pages_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -446,6 +527,70 @@ def test_pages_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (PagesClient, transports.PagesGrpcTransport, "grpc", grpc_helpers), + ( + PagesAsyncClient, + transports.PagesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_pages_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [page.ListPagesRequest, dict,]) def test_list_pages(request_type, transport: str = "grpc"): client = PagesClient( @@ -1595,6 +1740,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.PagesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PagesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = PagesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.PagesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2289,3 +2451,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (PagesClient, transports.PagesGrpcTransport), + (PagesAsyncClient, transports.PagesGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) 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 ddb1aa1a..e07cadc9 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_security_settings_service.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -420,6 +420,89 @@ def test_security_settings_service_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [SecuritySettingsServiceClient, SecuritySettingsServiceAsyncClient] +) +@mock.patch.object( + SecuritySettingsServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SecuritySettingsServiceClient), +) +@mock.patch.object( + SecuritySettingsServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SecuritySettingsServiceAsyncClient), +) +def test_security_settings_service_client_get_mtls_endpoint_and_cert_source( + client_class, +): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -456,25 +539,28 @@ def test_security_settings_service_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( SecuritySettingsServiceClient, transports.SecuritySettingsServiceGrpcTransport, "grpc", + grpc_helpers, ), ( SecuritySettingsServiceAsyncClient, transports.SecuritySettingsServiceGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_security_settings_service_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -510,6 +596,75 @@ def test_security_settings_service_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + SecuritySettingsServiceClient, + transports.SecuritySettingsServiceGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + SecuritySettingsServiceAsyncClient, + transports.SecuritySettingsServiceGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_security_settings_service_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [gcdc_security_settings.CreateSecuritySettingsRequest, dict,] ) @@ -2025,6 +2180,25 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SecuritySettingsServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecuritySettingsServiceClient( + client_options=options, transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecuritySettingsServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SecuritySettingsServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2664,3 +2838,39 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + ( + SecuritySettingsServiceClient, + transports.SecuritySettingsServiceGrpcTransport, + ), + ( + SecuritySettingsServiceAsyncClient, + transports.SecuritySettingsServiceGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) 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 e8de3e79..01348105 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_session_entity_types.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -415,6 +415,87 @@ def test_session_entity_types_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [SessionEntityTypesClient, SessionEntityTypesAsyncClient] +) +@mock.patch.object( + SessionEntityTypesClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SessionEntityTypesClient), +) +@mock.patch.object( + SessionEntityTypesAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SessionEntityTypesAsyncClient), +) +def test_session_entity_types_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -447,21 +528,28 @@ def test_session_entity_types_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (SessionEntityTypesClient, transports.SessionEntityTypesGrpcTransport, "grpc"), + ( + SessionEntityTypesClient, + transports.SessionEntityTypesGrpcTransport, + "grpc", + grpc_helpers, + ), ( SessionEntityTypesAsyncClient, transports.SessionEntityTypesGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_session_entity_types_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -497,6 +585,75 @@ def test_session_entity_types_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + SessionEntityTypesClient, + transports.SessionEntityTypesGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + SessionEntityTypesAsyncClient, + transports.SessionEntityTypesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_session_entity_types_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [session_entity_type.ListSessionEntityTypesRequest, dict,] ) @@ -1911,6 +2068,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SessionEntityTypesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionEntityTypesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionEntityTypesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SessionEntityTypesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2500,3 +2674,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (SessionEntityTypesClient, transports.SessionEntityTypesGrpcTransport), + ( + SessionEntityTypesAsyncClient, + transports.SessionEntityTypesGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py index 2fe01d2a..65891e48 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_sessions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -382,6 +382,83 @@ def test_sessions_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [SessionsClient, SessionsAsyncClient]) +@mock.patch.object( + SessionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SessionsClient) +) +@mock.patch.object( + SessionsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(SessionsAsyncClient), +) +def test_sessions_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -410,17 +487,23 @@ def test_sessions_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (SessionsClient, transports.SessionsGrpcTransport, "grpc"), - (SessionsAsyncClient, transports.SessionsGrpcAsyncIOTransport, "grpc_asyncio"), + (SessionsClient, transports.SessionsGrpcTransport, "grpc", grpc_helpers), + ( + SessionsAsyncClient, + transports.SessionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_sessions_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -454,6 +537,70 @@ def test_sessions_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (SessionsClient, transports.SessionsGrpcTransport, "grpc", grpc_helpers), + ( + SessionsAsyncClient, + transports.SessionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_sessions_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [session.DetectIntentRequest, dict,]) def test_detect_intent(request_type, transport: str = "grpc"): client = SessionsClient( @@ -949,6 +1096,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.SessionsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SessionsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.SessionsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -1736,3 +1900,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (SessionsClient, transports.SessionsGrpcTransport), + (SessionsAsyncClient, transports.SessionsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py index e7158371..32768937 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_test_cases.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -398,6 +399,83 @@ def test_test_cases_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [TestCasesClient, TestCasesAsyncClient]) +@mock.patch.object( + TestCasesClient, "DEFAULT_ENDPOINT", modify_default_endpoint(TestCasesClient) +) +@mock.patch.object( + TestCasesAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TestCasesAsyncClient), +) +def test_test_cases_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -430,21 +508,23 @@ def test_test_cases_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (TestCasesClient, transports.TestCasesGrpcTransport, "grpc"), + (TestCasesClient, transports.TestCasesGrpcTransport, "grpc", grpc_helpers), ( TestCasesAsyncClient, transports.TestCasesGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_test_cases_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -478,6 +558,70 @@ def test_test_cases_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (TestCasesClient, transports.TestCasesGrpcTransport, "grpc", grpc_helpers), + ( + TestCasesAsyncClient, + transports.TestCasesGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_test_cases_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [test_case.ListTestCasesRequest, dict,]) def test_list_test_cases(request_type, transport: str = "grpc"): client = TestCasesClient( @@ -2977,6 +3121,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.TestCasesGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TestCasesClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TestCasesClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.TestCasesGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -3825,3 +3986,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (TestCasesClient, transports.TestCasesGrpcTransport), + (TestCasesAsyncClient, transports.TestCasesGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) 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 549b0e39..c18d56c0 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_transition_route_groups.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -424,6 +424,87 @@ def test_transition_route_groups_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [TransitionRouteGroupsClient, TransitionRouteGroupsAsyncClient] +) +@mock.patch.object( + TransitionRouteGroupsClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TransitionRouteGroupsClient), +) +@mock.patch.object( + TransitionRouteGroupsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(TransitionRouteGroupsAsyncClient), +) +def test_transition_route_groups_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -460,25 +541,28 @@ def test_transition_route_groups_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ ( TransitionRouteGroupsClient, transports.TransitionRouteGroupsGrpcTransport, "grpc", + grpc_helpers, ), ( TransitionRouteGroupsAsyncClient, transports.TransitionRouteGroupsGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_transition_route_groups_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -514,6 +598,75 @@ def test_transition_route_groups_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + TransitionRouteGroupsClient, + transports.TransitionRouteGroupsGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + TransitionRouteGroupsAsyncClient, + transports.TransitionRouteGroupsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_transition_route_groups_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [transition_route_group.ListTransitionRouteGroupsRequest, dict,] ) @@ -1933,6 +2086,25 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.TransitionRouteGroupsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TransitionRouteGroupsClient( + client_options=options, transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TransitionRouteGroupsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.TransitionRouteGroupsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2630,3 +2802,36 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (TransitionRouteGroupsClient, transports.TransitionRouteGroupsGrpcTransport), + ( + TransitionRouteGroupsAsyncClient, + transports.TransitionRouteGroupsGrpcAsyncIOTransport, + ), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py index 4a8d37cc..9c04069c 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_versions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -385,6 +386,83 @@ def test_versions_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [VersionsClient, VersionsAsyncClient]) +@mock.patch.object( + VersionsClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VersionsClient) +) +@mock.patch.object( + VersionsAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(VersionsAsyncClient), +) +def test_versions_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -413,17 +491,23 @@ def test_versions_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (VersionsClient, transports.VersionsGrpcTransport, "grpc"), - (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport, "grpc_asyncio"), + (VersionsClient, transports.VersionsGrpcTransport, "grpc", grpc_helpers), + ( + VersionsAsyncClient, + transports.VersionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_versions_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -457,6 +541,70 @@ def test_versions_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (VersionsClient, transports.VersionsGrpcTransport, "grpc", grpc_helpers), + ( + VersionsAsyncClient, + transports.VersionsGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_versions_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [version.ListVersionsRequest, dict,]) def test_list_versions(request_type, transport: str = "grpc"): client = VersionsClient( @@ -2032,6 +2180,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.VersionsGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VersionsClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VersionsClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.VersionsGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2627,3 +2792,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (VersionsClient, transports.VersionsGrpcTransport), + (VersionsAsyncClient, transports.VersionsGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py b/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py index 30a7ca07..25d94094 100644 --- a/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py +++ b/tests/unit/gapic/dialogflowcx_v3beta1/test_webhooks.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -379,6 +379,83 @@ def test_webhooks_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [WebhooksClient, WebhooksAsyncClient]) +@mock.patch.object( + WebhooksClient, "DEFAULT_ENDPOINT", modify_default_endpoint(WebhooksClient) +) +@mock.patch.object( + WebhooksAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(WebhooksAsyncClient), +) +def test_webhooks_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -407,17 +484,23 @@ def test_webhooks_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (WebhooksClient, transports.WebhooksGrpcTransport, "grpc"), - (WebhooksAsyncClient, transports.WebhooksGrpcAsyncIOTransport, "grpc_asyncio"), + (WebhooksClient, transports.WebhooksGrpcTransport, "grpc", grpc_helpers), + ( + WebhooksAsyncClient, + transports.WebhooksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), ], ) def test_webhooks_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -451,6 +534,70 @@ def test_webhooks_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (WebhooksClient, transports.WebhooksGrpcTransport, "grpc", grpc_helpers), + ( + WebhooksAsyncClient, + transports.WebhooksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_webhooks_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "dialogflow.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/dialogflow", + ), + scopes=None, + default_host="dialogflow.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [webhook.ListWebhooksRequest, dict,]) def test_list_webhooks(request_type, transport: str = "grpc"): client = WebhooksClient( @@ -1629,6 +1776,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.WebhooksGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = WebhooksClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = WebhooksClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.WebhooksGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -2215,3 +2379,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (WebhooksClient, transports.WebhooksGrpcTransport), + (WebhooksAsyncClient, transports.WebhooksGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + )