diff --git a/packages/google-cloud-dialogflow-cx/.pre-commit-config.yaml b/packages/google-cloud-dialogflow-cx/.pre-commit-config.yaml
new file mode 100644
index 000000000000..6ad83346e261
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/.pre-commit-config.yaml
@@ -0,0 +1,17 @@
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+repos:
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v3.3.0
+ hooks:
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ - id: check-yaml
+- repo: https://github.com/psf/black
+ rev: 19.10b0
+ hooks:
+ - id: black
+- repo: https://gitlab.com/pycqa/flake8
+ rev: 3.8.4
+ hooks:
+ - id: flake8
diff --git a/packages/google-cloud-dialogflow-cx/CONTRIBUTING.rst b/packages/google-cloud-dialogflow-cx/CONTRIBUTING.rst
index 08864eac8148..cd40ffa76ac1 100644
--- a/packages/google-cloud-dialogflow-cx/CONTRIBUTING.rst
+++ b/packages/google-cloud-dialogflow-cx/CONTRIBUTING.rst
@@ -111,6 +111,16 @@ Coding Style
should point to the official ``googleapis`` checkout and the
the branch should be the main branch on that remote (``master``).
+- This repository contains configuration for the
+ `pre-commit `__ tool, which automates checking
+ our linters during a commit. If you have it installed on your ``$PATH``,
+ you can enable enforcing those checks via:
+
+.. code-block:: bash
+
+ $ pre-commit install
+ pre-commit installed at .git/hooks/pre-commit
+
Exceptions to PEP8:
- Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for
diff --git a/packages/google-cloud-dialogflow-cx/docs/conf.py b/packages/google-cloud-dialogflow-cx/docs/conf.py
index dcc6e5f658be..7610f0fc6746 100644
--- a/packages/google-cloud-dialogflow-cx/docs/conf.py
+++ b/packages/google-cloud-dialogflow-cx/docs/conf.py
@@ -345,10 +345,10 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
- "python": ("http://python.readthedocs.org/en/latest/", None),
- "google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
+ "python": ("https://python.readthedocs.org/en/latest/", None),
+ "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
- "grpc": ("https://grpc.io/grpc/python/", None),
+ "grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
}
diff --git a/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3/services.rst b/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3/services.rst
new file mode 100644
index 000000000000..eaaea2c8c744
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3/services.rst
@@ -0,0 +1,39 @@
+Services for Google Cloud Dialogflowcx v3 API
+=============================================
+
+.. automodule:: google.cloud.dialogflowcx_v3.services.agents
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.entity_types
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.environments
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.flows
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.intents
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.pages
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.security_settings_service
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.session_entity_types
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.sessions
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.transition_route_groups
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.versions
+ :members:
+ :inherited-members:
+.. automodule:: google.cloud.dialogflowcx_v3.services.webhooks
+ :members:
+ :inherited-members:
diff --git a/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3/types.rst b/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3/types.rst
new file mode 100644
index 000000000000..eee8146a1d62
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3/types.rst
@@ -0,0 +1,6 @@
+Types for Google Cloud Dialogflowcx v3 API
+==========================================
+
+.. automodule:: google.cloud.dialogflowcx_v3.types
+ :members:
+ :show-inheritance:
diff --git a/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3beta1/types.rst b/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3beta1/types.rst
index c1ad770ade2f..3c1160db7b56 100644
--- a/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3beta1/types.rst
+++ b/packages/google-cloud-dialogflow-cx/docs/dialogflowcx_v3beta1/types.rst
@@ -3,3 +3,4 @@ Types for Google Cloud Dialogflowcx v3beta1 API
.. automodule:: google.cloud.dialogflowcx_v3beta1.types
:members:
+ :show-inheritance:
diff --git a/packages/google-cloud-dialogflow-cx/docs/index.rst b/packages/google-cloud-dialogflow-cx/docs/index.rst
index 2d9225828197..6671a47b2318 100644
--- a/packages/google-cloud-dialogflow-cx/docs/index.rst
+++ b/packages/google-cloud-dialogflow-cx/docs/index.rst
@@ -8,6 +8,8 @@ API Reference
.. toctree::
:maxdepth: 2
+ dialogflowcx_v3/services
+ dialogflowcx_v3/types
dialogflowcx_v3beta1/services
dialogflowcx_v3beta1/types
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx/__init__.py
index 1d9845afdcae..44462fe62553 100644
--- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx/__init__.py
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx/__init__.py
@@ -15,209 +15,221 @@
# limitations under the License.
#
-from google.cloud.dialogflowcx_v3beta1.services.agents.async_client import (
- AgentsAsyncClient,
-)
-from google.cloud.dialogflowcx_v3beta1.services.agents.client import AgentsClient
-from google.cloud.dialogflowcx_v3beta1.services.entity_types.async_client import (
+from google.cloud.dialogflowcx_v3.services.agents.async_client import AgentsAsyncClient
+from google.cloud.dialogflowcx_v3.services.agents.client import AgentsClient
+from google.cloud.dialogflowcx_v3.services.entity_types.async_client import (
EntityTypesAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.entity_types.client import (
- EntityTypesClient,
-)
-from google.cloud.dialogflowcx_v3beta1.services.environments.async_client import (
+from google.cloud.dialogflowcx_v3.services.entity_types.client import EntityTypesClient
+from google.cloud.dialogflowcx_v3.services.environments.async_client import (
EnvironmentsAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.environments.client import (
- EnvironmentsClient,
-)
-from google.cloud.dialogflowcx_v3beta1.services.flows.async_client import (
- FlowsAsyncClient,
-)
-from google.cloud.dialogflowcx_v3beta1.services.flows.client import FlowsClient
-from google.cloud.dialogflowcx_v3beta1.services.intents.async_client import (
+from google.cloud.dialogflowcx_v3.services.environments.client import EnvironmentsClient
+from google.cloud.dialogflowcx_v3.services.flows.async_client import FlowsAsyncClient
+from google.cloud.dialogflowcx_v3.services.flows.client import FlowsClient
+from google.cloud.dialogflowcx_v3.services.intents.async_client import (
IntentsAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.intents.client import IntentsClient
-from google.cloud.dialogflowcx_v3beta1.services.pages.async_client import (
- PagesAsyncClient,
+from google.cloud.dialogflowcx_v3.services.intents.client import IntentsClient
+from google.cloud.dialogflowcx_v3.services.pages.async_client import PagesAsyncClient
+from google.cloud.dialogflowcx_v3.services.pages.client import PagesClient
+from google.cloud.dialogflowcx_v3.services.security_settings_service.async_client import (
+ SecuritySettingsServiceAsyncClient,
+)
+from google.cloud.dialogflowcx_v3.services.security_settings_service.client import (
+ SecuritySettingsServiceClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.pages.client import PagesClient
-from google.cloud.dialogflowcx_v3beta1.services.session_entity_types.async_client import (
+from google.cloud.dialogflowcx_v3.services.session_entity_types.async_client import (
SessionEntityTypesAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.session_entity_types.client import (
+from google.cloud.dialogflowcx_v3.services.session_entity_types.client import (
SessionEntityTypesClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.sessions.async_client import (
+from google.cloud.dialogflowcx_v3.services.sessions.async_client import (
SessionsAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.sessions.client import SessionsClient
-from google.cloud.dialogflowcx_v3beta1.services.transition_route_groups.async_client import (
+from google.cloud.dialogflowcx_v3.services.sessions.client import SessionsClient
+from google.cloud.dialogflowcx_v3.services.transition_route_groups.async_client import (
TransitionRouteGroupsAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.transition_route_groups.client import (
+from google.cloud.dialogflowcx_v3.services.transition_route_groups.client import (
TransitionRouteGroupsClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.versions.async_client import (
+from google.cloud.dialogflowcx_v3.services.versions.async_client import (
VersionsAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.versions.client import VersionsClient
-from google.cloud.dialogflowcx_v3beta1.services.webhooks.async_client import (
+from google.cloud.dialogflowcx_v3.services.versions.client import VersionsClient
+from google.cloud.dialogflowcx_v3.services.webhooks.async_client import (
WebhooksAsyncClient,
)
-from google.cloud.dialogflowcx_v3beta1.services.webhooks.client import WebhooksClient
-from google.cloud.dialogflowcx_v3beta1.types.agent import Agent
-from google.cloud.dialogflowcx_v3beta1.types.agent import CreateAgentRequest
-from google.cloud.dialogflowcx_v3beta1.types.agent import DeleteAgentRequest
-from google.cloud.dialogflowcx_v3beta1.types.agent import ExportAgentRequest
-from google.cloud.dialogflowcx_v3beta1.types.agent import ExportAgentResponse
-from google.cloud.dialogflowcx_v3beta1.types.agent import GetAgentRequest
-from google.cloud.dialogflowcx_v3beta1.types.agent import ListAgentsRequest
-from google.cloud.dialogflowcx_v3beta1.types.agent import ListAgentsResponse
-from google.cloud.dialogflowcx_v3beta1.types.agent import RestoreAgentRequest
-from google.cloud.dialogflowcx_v3beta1.types.agent import SpeechToTextSettings
-from google.cloud.dialogflowcx_v3beta1.types.agent import UpdateAgentRequest
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import AudioEncoding
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import InputAudioConfig
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import OutputAudioConfig
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import OutputAudioEncoding
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import SpeechModelVariant
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import SpeechWordInfo
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import SsmlVoiceGender
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import SynthesizeSpeechConfig
-from google.cloud.dialogflowcx_v3beta1.types.audio_config import VoiceSelectionParams
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import CreateEntityTypeRequest
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import DeleteEntityTypeRequest
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import EntityType
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import GetEntityTypeRequest
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import ListEntityTypesRequest
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import ListEntityTypesResponse
-from google.cloud.dialogflowcx_v3beta1.types.entity_type import UpdateEntityTypeRequest
-from google.cloud.dialogflowcx_v3beta1.types.environment import CreateEnvironmentRequest
-from google.cloud.dialogflowcx_v3beta1.types.environment import DeleteEnvironmentRequest
-from google.cloud.dialogflowcx_v3beta1.types.environment import Environment
-from google.cloud.dialogflowcx_v3beta1.types.environment import GetEnvironmentRequest
-from google.cloud.dialogflowcx_v3beta1.types.environment import ListEnvironmentsRequest
-from google.cloud.dialogflowcx_v3beta1.types.environment import ListEnvironmentsResponse
-from google.cloud.dialogflowcx_v3beta1.types.environment import (
+from google.cloud.dialogflowcx_v3.services.webhooks.client import WebhooksClient
+from google.cloud.dialogflowcx_v3.types.agent import Agent
+from google.cloud.dialogflowcx_v3.types.agent import CreateAgentRequest
+from google.cloud.dialogflowcx_v3.types.agent import DeleteAgentRequest
+from google.cloud.dialogflowcx_v3.types.agent import ExportAgentRequest
+from google.cloud.dialogflowcx_v3.types.agent import ExportAgentResponse
+from google.cloud.dialogflowcx_v3.types.agent import GetAgentRequest
+from google.cloud.dialogflowcx_v3.types.agent import ListAgentsRequest
+from google.cloud.dialogflowcx_v3.types.agent import ListAgentsResponse
+from google.cloud.dialogflowcx_v3.types.agent import RestoreAgentRequest
+from google.cloud.dialogflowcx_v3.types.agent import SpeechToTextSettings
+from google.cloud.dialogflowcx_v3.types.agent import UpdateAgentRequest
+from google.cloud.dialogflowcx_v3.types.audio_config import AudioEncoding
+from google.cloud.dialogflowcx_v3.types.audio_config import InputAudioConfig
+from google.cloud.dialogflowcx_v3.types.audio_config import OutputAudioConfig
+from google.cloud.dialogflowcx_v3.types.audio_config import OutputAudioEncoding
+from google.cloud.dialogflowcx_v3.types.audio_config import SpeechModelVariant
+from google.cloud.dialogflowcx_v3.types.audio_config import SpeechWordInfo
+from google.cloud.dialogflowcx_v3.types.audio_config import SsmlVoiceGender
+from google.cloud.dialogflowcx_v3.types.audio_config import SynthesizeSpeechConfig
+from google.cloud.dialogflowcx_v3.types.audio_config import VoiceSelectionParams
+from google.cloud.dialogflowcx_v3.types.entity_type import CreateEntityTypeRequest
+from google.cloud.dialogflowcx_v3.types.entity_type import DeleteEntityTypeRequest
+from google.cloud.dialogflowcx_v3.types.entity_type import EntityType
+from google.cloud.dialogflowcx_v3.types.entity_type import GetEntityTypeRequest
+from google.cloud.dialogflowcx_v3.types.entity_type import ListEntityTypesRequest
+from google.cloud.dialogflowcx_v3.types.entity_type import ListEntityTypesResponse
+from google.cloud.dialogflowcx_v3.types.entity_type import UpdateEntityTypeRequest
+from google.cloud.dialogflowcx_v3.types.environment import CreateEnvironmentRequest
+from google.cloud.dialogflowcx_v3.types.environment import DeleteEnvironmentRequest
+from google.cloud.dialogflowcx_v3.types.environment import Environment
+from google.cloud.dialogflowcx_v3.types.environment import GetEnvironmentRequest
+from google.cloud.dialogflowcx_v3.types.environment import ListEnvironmentsRequest
+from google.cloud.dialogflowcx_v3.types.environment import ListEnvironmentsResponse
+from google.cloud.dialogflowcx_v3.types.environment import (
LookupEnvironmentHistoryRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.environment import (
+from google.cloud.dialogflowcx_v3.types.environment import (
LookupEnvironmentHistoryResponse,
)
-from google.cloud.dialogflowcx_v3beta1.types.environment import UpdateEnvironmentRequest
-from google.cloud.dialogflowcx_v3beta1.types.flow import CreateFlowRequest
-from google.cloud.dialogflowcx_v3beta1.types.flow import DeleteFlowRequest
-from google.cloud.dialogflowcx_v3beta1.types.flow import Flow
-from google.cloud.dialogflowcx_v3beta1.types.flow import GetFlowRequest
-from google.cloud.dialogflowcx_v3beta1.types.flow import ListFlowsRequest
-from google.cloud.dialogflowcx_v3beta1.types.flow import ListFlowsResponse
-from google.cloud.dialogflowcx_v3beta1.types.flow import NluSettings
-from google.cloud.dialogflowcx_v3beta1.types.flow import TrainFlowRequest
-from google.cloud.dialogflowcx_v3beta1.types.flow import UpdateFlowRequest
-from google.cloud.dialogflowcx_v3beta1.types.fulfillment import Fulfillment
-from google.cloud.dialogflowcx_v3beta1.types.intent import CreateIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.intent import DeleteIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.intent import GetIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.intent import Intent
-from google.cloud.dialogflowcx_v3beta1.types.intent import IntentView
-from google.cloud.dialogflowcx_v3beta1.types.intent import ListIntentsRequest
-from google.cloud.dialogflowcx_v3beta1.types.intent import ListIntentsResponse
-from google.cloud.dialogflowcx_v3beta1.types.intent import UpdateIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.page import CreatePageRequest
-from google.cloud.dialogflowcx_v3beta1.types.page import DeletePageRequest
-from google.cloud.dialogflowcx_v3beta1.types.page import EventHandler
-from google.cloud.dialogflowcx_v3beta1.types.page import Form
-from google.cloud.dialogflowcx_v3beta1.types.page import GetPageRequest
-from google.cloud.dialogflowcx_v3beta1.types.page import ListPagesRequest
-from google.cloud.dialogflowcx_v3beta1.types.page import ListPagesResponse
-from google.cloud.dialogflowcx_v3beta1.types.page import Page
-from google.cloud.dialogflowcx_v3beta1.types.page import TransitionRoute
-from google.cloud.dialogflowcx_v3beta1.types.page import UpdatePageRequest
-from google.cloud.dialogflowcx_v3beta1.types.response_message import ResponseMessage
-from google.cloud.dialogflowcx_v3beta1.types.session import AudioInput
-from google.cloud.dialogflowcx_v3beta1.types.session import DetectIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.session import DetectIntentResponse
-from google.cloud.dialogflowcx_v3beta1.types.session import FulfillIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.session import FulfillIntentResponse
-from google.cloud.dialogflowcx_v3beta1.types.session import IntentInput
-from google.cloud.dialogflowcx_v3beta1.types.session import Match
-from google.cloud.dialogflowcx_v3beta1.types.session import MatchIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.session import MatchIntentResponse
-from google.cloud.dialogflowcx_v3beta1.types.session import QueryInput
-from google.cloud.dialogflowcx_v3beta1.types.session import QueryParameters
-from google.cloud.dialogflowcx_v3beta1.types.session import QueryResult
-from google.cloud.dialogflowcx_v3beta1.types.session import StreamingDetectIntentRequest
-from google.cloud.dialogflowcx_v3beta1.types.session import (
- StreamingDetectIntentResponse,
-)
-from google.cloud.dialogflowcx_v3beta1.types.session import StreamingRecognitionResult
-from google.cloud.dialogflowcx_v3beta1.types.session import TextInput
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
+from google.cloud.dialogflowcx_v3.types.environment import UpdateEnvironmentRequest
+from google.cloud.dialogflowcx_v3.types.flow import CreateFlowRequest
+from google.cloud.dialogflowcx_v3.types.flow import DeleteFlowRequest
+from google.cloud.dialogflowcx_v3.types.flow import Flow
+from google.cloud.dialogflowcx_v3.types.flow import GetFlowRequest
+from google.cloud.dialogflowcx_v3.types.flow import ListFlowsRequest
+from google.cloud.dialogflowcx_v3.types.flow import ListFlowsResponse
+from google.cloud.dialogflowcx_v3.types.flow import NluSettings
+from google.cloud.dialogflowcx_v3.types.flow import TrainFlowRequest
+from google.cloud.dialogflowcx_v3.types.flow import UpdateFlowRequest
+from google.cloud.dialogflowcx_v3.types.fulfillment import Fulfillment
+from google.cloud.dialogflowcx_v3.types.intent import CreateIntentRequest
+from google.cloud.dialogflowcx_v3.types.intent import DeleteIntentRequest
+from google.cloud.dialogflowcx_v3.types.intent import GetIntentRequest
+from google.cloud.dialogflowcx_v3.types.intent import Intent
+from google.cloud.dialogflowcx_v3.types.intent import IntentView
+from google.cloud.dialogflowcx_v3.types.intent import ListIntentsRequest
+from google.cloud.dialogflowcx_v3.types.intent import ListIntentsResponse
+from google.cloud.dialogflowcx_v3.types.intent import UpdateIntentRequest
+from google.cloud.dialogflowcx_v3.types.page import CreatePageRequest
+from google.cloud.dialogflowcx_v3.types.page import DeletePageRequest
+from google.cloud.dialogflowcx_v3.types.page import EventHandler
+from google.cloud.dialogflowcx_v3.types.page import Form
+from google.cloud.dialogflowcx_v3.types.page import GetPageRequest
+from google.cloud.dialogflowcx_v3.types.page import ListPagesRequest
+from google.cloud.dialogflowcx_v3.types.page import ListPagesResponse
+from google.cloud.dialogflowcx_v3.types.page import Page
+from google.cloud.dialogflowcx_v3.types.page import TransitionRoute
+from google.cloud.dialogflowcx_v3.types.page import UpdatePageRequest
+from google.cloud.dialogflowcx_v3.types.response_message import ResponseMessage
+from google.cloud.dialogflowcx_v3.types.security_settings import (
+ CreateSecuritySettingsRequest,
+)
+from google.cloud.dialogflowcx_v3.types.security_settings import (
+ DeleteSecuritySettingsRequest,
+)
+from google.cloud.dialogflowcx_v3.types.security_settings import (
+ GetSecuritySettingsRequest,
+)
+from google.cloud.dialogflowcx_v3.types.security_settings import (
+ ListSecuritySettingsRequest,
+)
+from google.cloud.dialogflowcx_v3.types.security_settings import (
+ ListSecuritySettingsResponse,
+)
+from google.cloud.dialogflowcx_v3.types.security_settings import SecuritySettings
+from google.cloud.dialogflowcx_v3.types.security_settings import (
+ UpdateSecuritySettingsRequest,
+)
+from google.cloud.dialogflowcx_v3.types.session import AudioInput
+from google.cloud.dialogflowcx_v3.types.session import DetectIntentRequest
+from google.cloud.dialogflowcx_v3.types.session import DetectIntentResponse
+from google.cloud.dialogflowcx_v3.types.session import DtmfInput
+from google.cloud.dialogflowcx_v3.types.session import EventInput
+from google.cloud.dialogflowcx_v3.types.session import FulfillIntentRequest
+from google.cloud.dialogflowcx_v3.types.session import FulfillIntentResponse
+from google.cloud.dialogflowcx_v3.types.session import IntentInput
+from google.cloud.dialogflowcx_v3.types.session import Match
+from google.cloud.dialogflowcx_v3.types.session import MatchIntentRequest
+from google.cloud.dialogflowcx_v3.types.session import MatchIntentResponse
+from google.cloud.dialogflowcx_v3.types.session import QueryInput
+from google.cloud.dialogflowcx_v3.types.session import QueryParameters
+from google.cloud.dialogflowcx_v3.types.session import QueryResult
+from google.cloud.dialogflowcx_v3.types.session import SentimentAnalysisResult
+from google.cloud.dialogflowcx_v3.types.session import StreamingDetectIntentRequest
+from google.cloud.dialogflowcx_v3.types.session import StreamingDetectIntentResponse
+from google.cloud.dialogflowcx_v3.types.session import StreamingRecognitionResult
+from google.cloud.dialogflowcx_v3.types.session import TextInput
+from google.cloud.dialogflowcx_v3.types.session_entity_type import (
CreateSessionEntityTypeRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
+from google.cloud.dialogflowcx_v3.types.session_entity_type import (
DeleteSessionEntityTypeRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
+from google.cloud.dialogflowcx_v3.types.session_entity_type import (
GetSessionEntityTypeRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
+from google.cloud.dialogflowcx_v3.types.session_entity_type import (
ListSessionEntityTypesRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
+from google.cloud.dialogflowcx_v3.types.session_entity_type import (
ListSessionEntityTypesResponse,
)
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
- SessionEntityType,
-)
-from google.cloud.dialogflowcx_v3beta1.types.session_entity_type import (
+from google.cloud.dialogflowcx_v3.types.session_entity_type import SessionEntityType
+from google.cloud.dialogflowcx_v3.types.session_entity_type import (
UpdateSessionEntityTypeRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
CreateTransitionRouteGroupRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
DeleteTransitionRouteGroupRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
GetTransitionRouteGroupRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
ListTransitionRouteGroupsRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
ListTransitionRouteGroupsResponse,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
TransitionRouteGroup,
)
-from google.cloud.dialogflowcx_v3beta1.types.transition_route_group import (
+from google.cloud.dialogflowcx_v3.types.transition_route_group import (
UpdateTransitionRouteGroupRequest,
)
-from google.cloud.dialogflowcx_v3beta1.types.version import (
- CreateVersionOperationMetadata,
-)
-from google.cloud.dialogflowcx_v3beta1.types.version import CreateVersionRequest
-from google.cloud.dialogflowcx_v3beta1.types.version import DeleteVersionRequest
-from google.cloud.dialogflowcx_v3beta1.types.version import GetVersionRequest
-from google.cloud.dialogflowcx_v3beta1.types.version import ListVersionsRequest
-from google.cloud.dialogflowcx_v3beta1.types.version import ListVersionsResponse
-from google.cloud.dialogflowcx_v3beta1.types.version import LoadVersionRequest
-from google.cloud.dialogflowcx_v3beta1.types.version import UpdateVersionRequest
-from google.cloud.dialogflowcx_v3beta1.types.version import Version
-from google.cloud.dialogflowcx_v3beta1.types.webhook import CreateWebhookRequest
-from google.cloud.dialogflowcx_v3beta1.types.webhook import DeleteWebhookRequest
-from google.cloud.dialogflowcx_v3beta1.types.webhook import GetWebhookRequest
-from google.cloud.dialogflowcx_v3beta1.types.webhook import ListWebhooksRequest
-from google.cloud.dialogflowcx_v3beta1.types.webhook import ListWebhooksResponse
-from google.cloud.dialogflowcx_v3beta1.types.webhook import PageInfo
-from google.cloud.dialogflowcx_v3beta1.types.webhook import SessionInfo
-from google.cloud.dialogflowcx_v3beta1.types.webhook import UpdateWebhookRequest
-from google.cloud.dialogflowcx_v3beta1.types.webhook import Webhook
-from google.cloud.dialogflowcx_v3beta1.types.webhook import WebhookRequest
-from google.cloud.dialogflowcx_v3beta1.types.webhook import WebhookResponse
+from google.cloud.dialogflowcx_v3.types.version import CreateVersionOperationMetadata
+from google.cloud.dialogflowcx_v3.types.version import CreateVersionRequest
+from google.cloud.dialogflowcx_v3.types.version import DeleteVersionRequest
+from google.cloud.dialogflowcx_v3.types.version import GetVersionRequest
+from google.cloud.dialogflowcx_v3.types.version import ListVersionsRequest
+from google.cloud.dialogflowcx_v3.types.version import ListVersionsResponse
+from google.cloud.dialogflowcx_v3.types.version import LoadVersionRequest
+from google.cloud.dialogflowcx_v3.types.version import UpdateVersionRequest
+from google.cloud.dialogflowcx_v3.types.version import Version
+from google.cloud.dialogflowcx_v3.types.webhook import CreateWebhookRequest
+from google.cloud.dialogflowcx_v3.types.webhook import DeleteWebhookRequest
+from google.cloud.dialogflowcx_v3.types.webhook import GetWebhookRequest
+from google.cloud.dialogflowcx_v3.types.webhook import ListWebhooksRequest
+from google.cloud.dialogflowcx_v3.types.webhook import ListWebhooksResponse
+from google.cloud.dialogflowcx_v3.types.webhook import PageInfo
+from google.cloud.dialogflowcx_v3.types.webhook import SessionInfo
+from google.cloud.dialogflowcx_v3.types.webhook import UpdateWebhookRequest
+from google.cloud.dialogflowcx_v3.types.webhook import Webhook
+from google.cloud.dialogflowcx_v3.types.webhook import WebhookRequest
+from google.cloud.dialogflowcx_v3.types.webhook import WebhookResponse
__all__ = (
"Agent",
@@ -231,6 +243,7 @@
"CreateFlowRequest",
"CreateIntentRequest",
"CreatePageRequest",
+ "CreateSecuritySettingsRequest",
"CreateSessionEntityTypeRequest",
"CreateTransitionRouteGroupRequest",
"CreateVersionOperationMetadata",
@@ -242,12 +255,14 @@
"DeleteFlowRequest",
"DeleteIntentRequest",
"DeletePageRequest",
+ "DeleteSecuritySettingsRequest",
"DeleteSessionEntityTypeRequest",
"DeleteTransitionRouteGroupRequest",
"DeleteVersionRequest",
"DeleteWebhookRequest",
"DetectIntentRequest",
"DetectIntentResponse",
+ "DtmfInput",
"EntityType",
"EntityTypesAsyncClient",
"EntityTypesClient",
@@ -255,6 +270,7 @@
"EnvironmentsAsyncClient",
"EnvironmentsClient",
"EventHandler",
+ "EventInput",
"ExportAgentRequest",
"ExportAgentResponse",
"Flow",
@@ -270,6 +286,7 @@
"GetFlowRequest",
"GetIntentRequest",
"GetPageRequest",
+ "GetSecuritySettingsRequest",
"GetSessionEntityTypeRequest",
"GetTransitionRouteGroupRequest",
"GetVersionRequest",
@@ -292,6 +309,8 @@
"ListIntentsResponse",
"ListPagesRequest",
"ListPagesResponse",
+ "ListSecuritySettingsRequest",
+ "ListSecuritySettingsResponse",
"ListSessionEntityTypesRequest",
"ListSessionEntityTypesResponse",
"ListTransitionRouteGroupsRequest",
@@ -318,6 +337,10 @@
"QueryResult",
"ResponseMessage",
"RestoreAgentRequest",
+ "SecuritySettings",
+ "SecuritySettingsServiceAsyncClient",
+ "SecuritySettingsServiceClient",
+ "SentimentAnalysisResult",
"SessionEntityType",
"SessionEntityTypesAsyncClient",
"SessionEntityTypesClient",
@@ -344,6 +367,7 @@
"UpdateFlowRequest",
"UpdateIntentRequest",
"UpdatePageRequest",
+ "UpdateSecuritySettingsRequest",
"UpdateSessionEntityTypeRequest",
"UpdateTransitionRouteGroupRequest",
"UpdateVersionRequest",
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/__init__.py
new file mode 100644
index 000000000000..791c87bcd59c
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/__init__.py
@@ -0,0 +1,295 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from .services.agents import AgentsClient
+from .services.entity_types import EntityTypesClient
+from .services.environments import EnvironmentsClient
+from .services.flows import FlowsClient
+from .services.intents import IntentsClient
+from .services.pages import PagesClient
+from .services.security_settings_service import SecuritySettingsServiceClient
+from .services.session_entity_types import SessionEntityTypesClient
+from .services.sessions import SessionsClient
+from .services.transition_route_groups import TransitionRouteGroupsClient
+from .services.versions import VersionsClient
+from .services.webhooks import WebhooksClient
+from .types.agent import Agent
+from .types.agent import CreateAgentRequest
+from .types.agent import DeleteAgentRequest
+from .types.agent import ExportAgentRequest
+from .types.agent import ExportAgentResponse
+from .types.agent import GetAgentRequest
+from .types.agent import ListAgentsRequest
+from .types.agent import ListAgentsResponse
+from .types.agent import RestoreAgentRequest
+from .types.agent import SpeechToTextSettings
+from .types.agent import UpdateAgentRequest
+from .types.audio_config import AudioEncoding
+from .types.audio_config import InputAudioConfig
+from .types.audio_config import OutputAudioConfig
+from .types.audio_config import OutputAudioEncoding
+from .types.audio_config import SpeechModelVariant
+from .types.audio_config import SpeechWordInfo
+from .types.audio_config import SsmlVoiceGender
+from .types.audio_config import SynthesizeSpeechConfig
+from .types.audio_config import VoiceSelectionParams
+from .types.entity_type import CreateEntityTypeRequest
+from .types.entity_type import DeleteEntityTypeRequest
+from .types.entity_type import EntityType
+from .types.entity_type import GetEntityTypeRequest
+from .types.entity_type import ListEntityTypesRequest
+from .types.entity_type import ListEntityTypesResponse
+from .types.entity_type import UpdateEntityTypeRequest
+from .types.environment import CreateEnvironmentRequest
+from .types.environment import DeleteEnvironmentRequest
+from .types.environment import Environment
+from .types.environment import GetEnvironmentRequest
+from .types.environment import ListEnvironmentsRequest
+from .types.environment import ListEnvironmentsResponse
+from .types.environment import LookupEnvironmentHistoryRequest
+from .types.environment import LookupEnvironmentHistoryResponse
+from .types.environment import UpdateEnvironmentRequest
+from .types.flow import CreateFlowRequest
+from .types.flow import DeleteFlowRequest
+from .types.flow import Flow
+from .types.flow import GetFlowRequest
+from .types.flow import ListFlowsRequest
+from .types.flow import ListFlowsResponse
+from .types.flow import NluSettings
+from .types.flow import TrainFlowRequest
+from .types.flow import UpdateFlowRequest
+from .types.fulfillment import Fulfillment
+from .types.intent import CreateIntentRequest
+from .types.intent import DeleteIntentRequest
+from .types.intent import GetIntentRequest
+from .types.intent import Intent
+from .types.intent import IntentView
+from .types.intent import ListIntentsRequest
+from .types.intent import ListIntentsResponse
+from .types.intent import UpdateIntentRequest
+from .types.page import CreatePageRequest
+from .types.page import DeletePageRequest
+from .types.page import EventHandler
+from .types.page import Form
+from .types.page import GetPageRequest
+from .types.page import ListPagesRequest
+from .types.page import ListPagesResponse
+from .types.page import Page
+from .types.page import TransitionRoute
+from .types.page import UpdatePageRequest
+from .types.response_message import ResponseMessage
+from .types.security_settings import CreateSecuritySettingsRequest
+from .types.security_settings import DeleteSecuritySettingsRequest
+from .types.security_settings import GetSecuritySettingsRequest
+from .types.security_settings import ListSecuritySettingsRequest
+from .types.security_settings import ListSecuritySettingsResponse
+from .types.security_settings import SecuritySettings
+from .types.security_settings import UpdateSecuritySettingsRequest
+from .types.session import AudioInput
+from .types.session import DetectIntentRequest
+from .types.session import DetectIntentResponse
+from .types.session import DtmfInput
+from .types.session import EventInput
+from .types.session import FulfillIntentRequest
+from .types.session import FulfillIntentResponse
+from .types.session import IntentInput
+from .types.session import Match
+from .types.session import MatchIntentRequest
+from .types.session import MatchIntentResponse
+from .types.session import QueryInput
+from .types.session import QueryParameters
+from .types.session import QueryResult
+from .types.session import SentimentAnalysisResult
+from .types.session import StreamingDetectIntentRequest
+from .types.session import StreamingDetectIntentResponse
+from .types.session import StreamingRecognitionResult
+from .types.session import TextInput
+from .types.session_entity_type import CreateSessionEntityTypeRequest
+from .types.session_entity_type import DeleteSessionEntityTypeRequest
+from .types.session_entity_type import GetSessionEntityTypeRequest
+from .types.session_entity_type import ListSessionEntityTypesRequest
+from .types.session_entity_type import ListSessionEntityTypesResponse
+from .types.session_entity_type import SessionEntityType
+from .types.session_entity_type import UpdateSessionEntityTypeRequest
+from .types.transition_route_group import CreateTransitionRouteGroupRequest
+from .types.transition_route_group import DeleteTransitionRouteGroupRequest
+from .types.transition_route_group import GetTransitionRouteGroupRequest
+from .types.transition_route_group import ListTransitionRouteGroupsRequest
+from .types.transition_route_group import ListTransitionRouteGroupsResponse
+from .types.transition_route_group import TransitionRouteGroup
+from .types.transition_route_group import UpdateTransitionRouteGroupRequest
+from .types.version import CreateVersionOperationMetadata
+from .types.version import CreateVersionRequest
+from .types.version import DeleteVersionRequest
+from .types.version import GetVersionRequest
+from .types.version import ListVersionsRequest
+from .types.version import ListVersionsResponse
+from .types.version import LoadVersionRequest
+from .types.version import UpdateVersionRequest
+from .types.version import Version
+from .types.webhook import CreateWebhookRequest
+from .types.webhook import DeleteWebhookRequest
+from .types.webhook import GetWebhookRequest
+from .types.webhook import ListWebhooksRequest
+from .types.webhook import ListWebhooksResponse
+from .types.webhook import PageInfo
+from .types.webhook import SessionInfo
+from .types.webhook import UpdateWebhookRequest
+from .types.webhook import Webhook
+from .types.webhook import WebhookRequest
+from .types.webhook import WebhookResponse
+
+
+__all__ = (
+ "Agent",
+ "AgentsClient",
+ "AudioEncoding",
+ "AudioInput",
+ "CreateAgentRequest",
+ "CreateEntityTypeRequest",
+ "CreateEnvironmentRequest",
+ "CreateFlowRequest",
+ "CreateIntentRequest",
+ "CreatePageRequest",
+ "CreateSecuritySettingsRequest",
+ "CreateSessionEntityTypeRequest",
+ "CreateTransitionRouteGroupRequest",
+ "CreateVersionOperationMetadata",
+ "CreateVersionRequest",
+ "CreateWebhookRequest",
+ "DeleteAgentRequest",
+ "DeleteEntityTypeRequest",
+ "DeleteEnvironmentRequest",
+ "DeleteFlowRequest",
+ "DeleteIntentRequest",
+ "DeletePageRequest",
+ "DeleteSecuritySettingsRequest",
+ "DeleteSessionEntityTypeRequest",
+ "DeleteTransitionRouteGroupRequest",
+ "DeleteVersionRequest",
+ "DeleteWebhookRequest",
+ "DetectIntentRequest",
+ "DetectIntentResponse",
+ "DtmfInput",
+ "EntityType",
+ "EntityTypesClient",
+ "Environment",
+ "EnvironmentsClient",
+ "EventHandler",
+ "EventInput",
+ "ExportAgentRequest",
+ "ExportAgentResponse",
+ "Flow",
+ "FlowsClient",
+ "Form",
+ "FulfillIntentRequest",
+ "FulfillIntentResponse",
+ "Fulfillment",
+ "GetAgentRequest",
+ "GetEntityTypeRequest",
+ "GetEnvironmentRequest",
+ "GetFlowRequest",
+ "GetIntentRequest",
+ "GetPageRequest",
+ "GetSecuritySettingsRequest",
+ "GetSessionEntityTypeRequest",
+ "GetTransitionRouteGroupRequest",
+ "GetVersionRequest",
+ "GetWebhookRequest",
+ "InputAudioConfig",
+ "Intent",
+ "IntentInput",
+ "IntentView",
+ "IntentsClient",
+ "ListAgentsRequest",
+ "ListAgentsResponse",
+ "ListEntityTypesRequest",
+ "ListEntityTypesResponse",
+ "ListEnvironmentsRequest",
+ "ListEnvironmentsResponse",
+ "ListFlowsRequest",
+ "ListFlowsResponse",
+ "ListIntentsRequest",
+ "ListIntentsResponse",
+ "ListPagesRequest",
+ "ListPagesResponse",
+ "ListSecuritySettingsRequest",
+ "ListSecuritySettingsResponse",
+ "ListSessionEntityTypesRequest",
+ "ListSessionEntityTypesResponse",
+ "ListTransitionRouteGroupsRequest",
+ "ListTransitionRouteGroupsResponse",
+ "ListVersionsRequest",
+ "ListVersionsResponse",
+ "ListWebhooksRequest",
+ "ListWebhooksResponse",
+ "LoadVersionRequest",
+ "LookupEnvironmentHistoryRequest",
+ "LookupEnvironmentHistoryResponse",
+ "Match",
+ "MatchIntentRequest",
+ "MatchIntentResponse",
+ "NluSettings",
+ "OutputAudioConfig",
+ "OutputAudioEncoding",
+ "Page",
+ "PageInfo",
+ "PagesClient",
+ "QueryInput",
+ "QueryParameters",
+ "QueryResult",
+ "ResponseMessage",
+ "RestoreAgentRequest",
+ "SecuritySettings",
+ "SecuritySettingsServiceClient",
+ "SentimentAnalysisResult",
+ "SessionEntityType",
+ "SessionEntityTypesClient",
+ "SessionInfo",
+ "SessionsClient",
+ "SpeechModelVariant",
+ "SpeechToTextSettings",
+ "SpeechWordInfo",
+ "SsmlVoiceGender",
+ "StreamingDetectIntentRequest",
+ "StreamingDetectIntentResponse",
+ "StreamingRecognitionResult",
+ "SynthesizeSpeechConfig",
+ "TextInput",
+ "TrainFlowRequest",
+ "TransitionRoute",
+ "TransitionRouteGroup",
+ "TransitionRouteGroupsClient",
+ "UpdateAgentRequest",
+ "UpdateEntityTypeRequest",
+ "UpdateEnvironmentRequest",
+ "UpdateFlowRequest",
+ "UpdateIntentRequest",
+ "UpdatePageRequest",
+ "UpdateSecuritySettingsRequest",
+ "UpdateSessionEntityTypeRequest",
+ "UpdateTransitionRouteGroupRequest",
+ "UpdateVersionRequest",
+ "UpdateWebhookRequest",
+ "Version",
+ "VersionsClient",
+ "VoiceSelectionParams",
+ "Webhook",
+ "WebhookRequest",
+ "WebhookResponse",
+ "WebhooksClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/py.typed b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/py.typed
new file mode 100644
index 000000000000..60fdca4946ed
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/py.typed
@@ -0,0 +1,2 @@
+# Marker file for PEP 561.
+# The google-cloud-dialogflowcx package uses inline types.
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/__init__.py
new file mode 100644
index 000000000000..42ffdf2bc43d
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/__init__.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3beta1/types/gcs.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/__init__.py
similarity index 81%
rename from packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3beta1/types/gcs.py
rename to packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/__init__.py
index 32c9622b3e72..4bcbd7ac8dee 100644
--- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3beta1/types/gcs.py
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/__init__.py
@@ -15,8 +15,10 @@
# limitations under the License.
#
+from .client import AgentsClient
+from .async_client import AgentsAsyncClient
-__protobuf__ = proto.module(package="google.cloud.dialogflow.cx.v3beta1", manifest={},)
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
+__all__ = (
+ "AgentsClient",
+ "AgentsAsyncClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/async_client.py
new file mode 100644
index 000000000000..49935e19fba9
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/async_client.py
@@ -0,0 +1,707 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.dialogflowcx_v3.services.agents import pagers
+from google.cloud.dialogflowcx_v3.types import agent
+from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
+from google.protobuf import empty_pb2 as empty # type: ignore
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import struct_pb2 as struct # type: ignore
+
+from .transports.base import AgentsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import AgentsGrpcAsyncIOTransport
+from .client import AgentsClient
+
+
+class AgentsAsyncClient:
+ """Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent]."""
+
+ _client: AgentsClient
+
+ DEFAULT_ENDPOINT = AgentsClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = AgentsClient.DEFAULT_MTLS_ENDPOINT
+
+ agent_path = staticmethod(AgentsClient.agent_path)
+ parse_agent_path = staticmethod(AgentsClient.parse_agent_path)
+ flow_path = staticmethod(AgentsClient.flow_path)
+ parse_flow_path = staticmethod(AgentsClient.parse_flow_path)
+
+ common_billing_account_path = staticmethod(AgentsClient.common_billing_account_path)
+ parse_common_billing_account_path = staticmethod(
+ AgentsClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(AgentsClient.common_folder_path)
+ parse_common_folder_path = staticmethod(AgentsClient.parse_common_folder_path)
+
+ common_organization_path = staticmethod(AgentsClient.common_organization_path)
+ parse_common_organization_path = staticmethod(
+ AgentsClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(AgentsClient.common_project_path)
+ parse_common_project_path = staticmethod(AgentsClient.parse_common_project_path)
+
+ common_location_path = staticmethod(AgentsClient.common_location_path)
+ parse_common_location_path = staticmethod(AgentsClient.parse_common_location_path)
+
+ from_service_account_file = AgentsClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> AgentsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ AgentsTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(AgentsClient).get_transport_class, type(AgentsClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, AgentsTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the agents client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.AgentsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = AgentsClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def list_agents(
+ self,
+ request: agent.ListAgentsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListAgentsAsyncPager:
+ r"""Returns the list of all agents in the specified
+ location.
+
+ Args:
+ request (:class:`~.agent.ListAgentsRequest`):
+ The request object. The request message for
+ [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents].
+ parent (:class:`str`):
+ Required. The location to list all agents for. Format:
+ ``projects//locations/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListAgentsAsyncPager:
+ The response message for
+ [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = agent.ListAgentsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_agents,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListAgentsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_agent(
+ self,
+ request: agent.GetAgentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> agent.Agent:
+ r"""Retrieves the specified agent.
+
+ Args:
+ request (:class:`~.agent.GetAgentRequest`):
+ The request object. The request message for
+ [Agents.GetAgent][google.cloud.dialogflow.cx.v3.Agents.GetAgent].
+ name (:class:`str`):
+ Required. The name of the agent. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.agent.Agent:
+ Agents are best described as Natural Language
+ Understanding (NLU) modules that transform user requests
+ into actionable data. You can include agents in your
+ app, product, or service to determine user intent and
+ respond to the user in a natural way.
+
+ After you create an agent, you can add
+ [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity
+ Types][google.cloud.dialogflow.cx.v3.EntityType],
+ [Flows][google.cloud.dialogflow.cx.v3.Flow],
+ [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment],
+ [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and
+ so on to manage the conversation flows..
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = agent.GetAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_agent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def create_agent(
+ self,
+ request: gcdc_agent.CreateAgentRequest = None,
+ *,
+ parent: str = None,
+ agent: gcdc_agent.Agent = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_agent.Agent:
+ r"""Creates an agent in the specified location.
+
+ Args:
+ request (:class:`~.gcdc_agent.CreateAgentRequest`):
+ The request object. The request message for
+ [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent].
+ parent (:class:`str`):
+ Required. The location to create a agent for. Format:
+ ``projects//locations/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ agent (:class:`~.gcdc_agent.Agent`):
+ Required. The agent to create.
+ This corresponds to the ``agent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_agent.Agent:
+ Agents are best described as Natural Language
+ Understanding (NLU) modules that transform user requests
+ into actionable data. You can include agents in your
+ app, product, or service to determine user intent and
+ respond to the user in a natural way.
+
+ After you create an agent, you can add
+ [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity
+ Types][google.cloud.dialogflow.cx.v3.EntityType],
+ [Flows][google.cloud.dialogflow.cx.v3.Flow],
+ [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment],
+ [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and
+ so on to manage the conversation flows..
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_agent.CreateAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if agent is not None:
+ request.agent = agent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_agent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def update_agent(
+ self,
+ request: gcdc_agent.UpdateAgentRequest = None,
+ *,
+ agent: gcdc_agent.Agent = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_agent.Agent:
+ r"""Updates the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_agent.UpdateAgentRequest`):
+ The request object. The request message for
+ [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent].
+ agent (:class:`~.gcdc_agent.Agent`):
+ Required. The agent to update.
+ This corresponds to the ``agent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ The mask to control which fields get
+ updated. If the mask is not present, all
+ fields will be updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_agent.Agent:
+ Agents are best described as Natural Language
+ Understanding (NLU) modules that transform user requests
+ into actionable data. You can include agents in your
+ app, product, or service to determine user intent and
+ respond to the user in a natural way.
+
+ After you create an agent, you can add
+ [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity
+ Types][google.cloud.dialogflow.cx.v3.EntityType],
+ [Flows][google.cloud.dialogflow.cx.v3.Flow],
+ [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment],
+ [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and
+ so on to manage the conversation flows..
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_agent.UpdateAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if agent is not None:
+ request.agent = agent
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_agent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("agent.name", request.agent.name),)
+ ),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def delete_agent(
+ self,
+ request: agent.DeleteAgentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified agent.
+
+ Args:
+ request (:class:`~.agent.DeleteAgentRequest`):
+ The request object. The request message for
+ [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3.Agents.DeleteAgent].
+ name (:class:`str`):
+ Required. The name of the agent to delete. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = agent.DeleteAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.delete_agent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ async def export_agent(
+ self,
+ request: agent.ExportAgentRequest = None,
+ *,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Exports the specified agent to a binary file.
+
+ Args:
+ request (:class:`~.agent.ExportAgentRequest`):
+ The request object. The request message for
+ [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent].
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.agent.ExportAgentResponse``: The response
+ message for
+ [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent].
+
+ """
+ # Create or coerce a protobuf request object.
+
+ request = agent.ExportAgentRequest(request)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.export_agent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ agent.ExportAgentResponse,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def restore_agent(
+ self,
+ request: agent.RestoreAgentRequest = None,
+ *,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Restores the specified agent from a binary file.
+ Replaces the current agent with a new one. Note that all
+ existing resources in agent (e.g. intents, entity types,
+ flows) will be removed.
+
+ Args:
+ request (:class:`~.agent.RestoreAgentRequest`):
+ The request object. The request message for
+ [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3.Agents.RestoreAgent].
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.empty.Empty``: A generic empty message that
+ you can re-use to avoid defining duplicated empty
+ messages in your APIs. A typical example is to use it as
+ the request or the response type of an API method. For
+ instance:
+
+ ::
+
+ service Foo {
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ }
+
+ The JSON representation for ``Empty`` is empty JSON
+ object ``{}``.
+
+ """
+ # Create or coerce a protobuf request object.
+
+ request = agent.RestoreAgentRequest(request)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.restore_agent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ empty.Empty,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("AgentsAsyncClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/client.py
new file mode 100644
index 000000000000..67b8d2e78f03
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/client.py
@@ -0,0 +1,927 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from distutils import util
+import os
+import re
+from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
+import pkg_resources
+
+from google.api_core import client_options as client_options_lib # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport import mtls # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+from google.auth.exceptions import MutualTLSChannelError # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.dialogflowcx_v3.services.agents import pagers
+from google.cloud.dialogflowcx_v3.types import agent
+from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
+from google.protobuf import empty_pb2 as empty # type: ignore
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import struct_pb2 as struct # type: ignore
+
+from .transports.base import AgentsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc import AgentsGrpcTransport
+from .transports.grpc_asyncio import AgentsGrpcAsyncIOTransport
+
+
+class AgentsClientMeta(type):
+ """Metaclass for the Agents client.
+
+ This provides class-level methods for building and retrieving
+ support objects (e.g. transport) without polluting the client instance
+ objects.
+ """
+
+ _transport_registry = OrderedDict() # type: Dict[str, Type[AgentsTransport]]
+ _transport_registry["grpc"] = AgentsGrpcTransport
+ _transport_registry["grpc_asyncio"] = AgentsGrpcAsyncIOTransport
+
+ def get_transport_class(cls, label: str = None,) -> Type[AgentsTransport]:
+ """Return an appropriate transport class.
+
+ Args:
+ label: The name of the desired transport. If none is
+ provided, then the first transport in the registry is used.
+
+ Returns:
+ The transport class to use.
+ """
+ # If a specific transport is requested, return that one.
+ if label:
+ return cls._transport_registry[label]
+
+ # No transport is requested; return the default (that is, the first one
+ # in the dictionary).
+ return next(iter(cls._transport_registry.values()))
+
+
+class AgentsClient(metaclass=AgentsClientMeta):
+ """Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent]."""
+
+ @staticmethod
+ def _get_default_mtls_endpoint(api_endpoint):
+ """Convert api endpoint to mTLS endpoint.
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
+ Args:
+ api_endpoint (Optional[str]): the api endpoint to convert.
+ Returns:
+ str: converted mTLS api endpoint.
+ """
+ if not api_endpoint:
+ return api_endpoint
+
+ mtls_endpoint_re = re.compile(
+ r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?"
+ )
+
+ m = mtls_endpoint_re.match(api_endpoint)
+ name, mtls, sandbox, googledomain = m.groups()
+ if mtls or not googledomain:
+ return api_endpoint
+
+ if sandbox:
+ return api_endpoint.replace(
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
+ )
+
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
+
+ DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
+ DEFAULT_ENDPOINT
+ )
+
+ @classmethod
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ file.
+
+ Args:
+ filename (str): The path to the service account private key json
+ file.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ {@api.name}: The constructed client.
+ """
+ credentials = service_account.Credentials.from_service_account_file(filename)
+ kwargs["credentials"] = credentials
+ return cls(*args, **kwargs)
+
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> AgentsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ AgentsTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def agent_path(project: str, location: str, agent: str,) -> str:
+ """Return a fully-qualified agent string."""
+ return "projects/{project}/locations/{location}/agents/{agent}".format(
+ project=project, location=location, agent=agent,
+ )
+
+ @staticmethod
+ def parse_agent_path(path: str) -> Dict[str, str]:
+ """Parse a agent path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def flow_path(project: str, location: str, agent: str, flow: str,) -> str:
+ """Return a fully-qualified flow string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(
+ project=project, location=location, agent=agent, flow=flow,
+ )
+
+ @staticmethod
+ def parse_flow_path(path: str) -> Dict[str, str]:
+ """Parse a flow path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[credentials.Credentials] = None,
+ transport: Union[str, AgentsTransport, None] = None,
+ client_options: Optional[client_options_lib.ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the agents client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.AgentsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (client_options_lib.ClientOptions): Custom options for the
+ client. It won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+ if isinstance(client_options, dict):
+ client_options = client_options_lib.from_dict(client_options)
+ if client_options is None:
+ client_options = client_options_lib.ClientOptions()
+
+ # Create SSL credentials for mutual TLS if needed.
+ use_client_cert = bool(
+ util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
+ )
+
+ ssl_credentials = None
+ is_mtls = False
+ if use_client_cert:
+ if client_options.client_cert_source:
+ import grpc # type: ignore
+
+ cert, key = client_options.client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ is_mtls = True
+ else:
+ creds = SslCredentials()
+ is_mtls = creds.is_mtls
+ ssl_credentials = creds.ssl_credentials if is_mtls else 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":
+ api_endpoint = (
+ self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
+ )
+ else:
+ raise MutualTLSChannelError(
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ )
+
+ # 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:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its credentials directly."
+ )
+ if client_options.scopes:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its scopes directly."
+ )
+ self._transport = transport
+ else:
+ Transport = type(self).get_transport_class(transport)
+ self._transport = Transport(
+ credentials=credentials,
+ credentials_file=client_options.credentials_file,
+ host=api_endpoint,
+ scopes=client_options.scopes,
+ ssl_channel_credentials=ssl_credentials,
+ quota_project_id=client_options.quota_project_id,
+ client_info=client_info,
+ )
+
+ def list_agents(
+ self,
+ request: agent.ListAgentsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListAgentsPager:
+ r"""Returns the list of all agents in the specified
+ location.
+
+ Args:
+ request (:class:`~.agent.ListAgentsRequest`):
+ The request object. The request message for
+ [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents].
+ parent (:class:`str`):
+ Required. The location to list all agents for. Format:
+ ``projects//locations/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListAgentsPager:
+ The response message for
+ [Agents.ListAgents][google.cloud.dialogflow.cx.v3.Agents.ListAgents].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a agent.ListAgentsRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, agent.ListAgentsRequest):
+ request = agent.ListAgentsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.list_agents]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.ListAgentsPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_agent(
+ self,
+ request: agent.GetAgentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> agent.Agent:
+ r"""Retrieves the specified agent.
+
+ Args:
+ request (:class:`~.agent.GetAgentRequest`):
+ The request object. The request message for
+ [Agents.GetAgent][google.cloud.dialogflow.cx.v3.Agents.GetAgent].
+ name (:class:`str`):
+ Required. The name of the agent. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.agent.Agent:
+ Agents are best described as Natural Language
+ Understanding (NLU) modules that transform user requests
+ into actionable data. You can include agents in your
+ app, product, or service to determine user intent and
+ respond to the user in a natural way.
+
+ After you create an agent, you can add
+ [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity
+ Types][google.cloud.dialogflow.cx.v3.EntityType],
+ [Flows][google.cloud.dialogflow.cx.v3.Flow],
+ [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment],
+ [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and
+ so on to manage the conversation flows..
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a agent.GetAgentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, agent.GetAgentRequest):
+ request = agent.GetAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_agent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def create_agent(
+ self,
+ request: gcdc_agent.CreateAgentRequest = None,
+ *,
+ parent: str = None,
+ agent: gcdc_agent.Agent = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_agent.Agent:
+ r"""Creates an agent in the specified location.
+
+ Args:
+ request (:class:`~.gcdc_agent.CreateAgentRequest`):
+ The request object. The request message for
+ [Agents.CreateAgent][google.cloud.dialogflow.cx.v3.Agents.CreateAgent].
+ parent (:class:`str`):
+ Required. The location to create a agent for. Format:
+ ``projects//locations/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ agent (:class:`~.gcdc_agent.Agent`):
+ Required. The agent to create.
+ This corresponds to the ``agent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_agent.Agent:
+ Agents are best described as Natural Language
+ Understanding (NLU) modules that transform user requests
+ into actionable data. You can include agents in your
+ app, product, or service to determine user intent and
+ respond to the user in a natural way.
+
+ After you create an agent, you can add
+ [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity
+ Types][google.cloud.dialogflow.cx.v3.EntityType],
+ [Flows][google.cloud.dialogflow.cx.v3.Flow],
+ [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment],
+ [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and
+ so on to manage the conversation flows..
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_agent.CreateAgentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_agent.CreateAgentRequest):
+ request = gcdc_agent.CreateAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if agent is not None:
+ request.agent = agent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_agent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def update_agent(
+ self,
+ request: gcdc_agent.UpdateAgentRequest = None,
+ *,
+ agent: gcdc_agent.Agent = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_agent.Agent:
+ r"""Updates the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_agent.UpdateAgentRequest`):
+ The request object. The request message for
+ [Agents.UpdateAgent][google.cloud.dialogflow.cx.v3.Agents.UpdateAgent].
+ agent (:class:`~.gcdc_agent.Agent`):
+ Required. The agent to update.
+ This corresponds to the ``agent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ The mask to control which fields get
+ updated. If the mask is not present, all
+ fields will be updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_agent.Agent:
+ Agents are best described as Natural Language
+ Understanding (NLU) modules that transform user requests
+ into actionable data. You can include agents in your
+ app, product, or service to determine user intent and
+ respond to the user in a natural way.
+
+ After you create an agent, you can add
+ [Intents][google.cloud.dialogflow.cx.v3.Intent], [Entity
+ Types][google.cloud.dialogflow.cx.v3.EntityType],
+ [Flows][google.cloud.dialogflow.cx.v3.Flow],
+ [Fulfillments][google.cloud.dialogflow.cx.v3.Fulfillment],
+ [Webhooks][google.cloud.dialogflow.cx.v3.Webhook], and
+ so on to manage the conversation flows..
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_agent.UpdateAgentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_agent.UpdateAgentRequest):
+ request = gcdc_agent.UpdateAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if agent is not None:
+ request.agent = agent
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_agent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("agent.name", request.agent.name),)
+ ),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def delete_agent(
+ self,
+ request: agent.DeleteAgentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified agent.
+
+ Args:
+ request (:class:`~.agent.DeleteAgentRequest`):
+ The request object. The request message for
+ [Agents.DeleteAgent][google.cloud.dialogflow.cx.v3.Agents.DeleteAgent].
+ name (:class:`str`):
+ Required. The name of the agent to delete. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a agent.DeleteAgentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, agent.DeleteAgentRequest):
+ request = agent.DeleteAgentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.delete_agent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ def export_agent(
+ self,
+ request: agent.ExportAgentRequest = None,
+ *,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Exports the specified agent to a binary file.
+
+ Args:
+ request (:class:`~.agent.ExportAgentRequest`):
+ The request object. The request message for
+ [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent].
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.agent.ExportAgentResponse``: The response
+ message for
+ [Agents.ExportAgent][google.cloud.dialogflow.cx.v3.Agents.ExportAgent].
+
+ """
+ # Create or coerce a protobuf request object.
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a agent.ExportAgentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, agent.ExportAgentRequest):
+ request = agent.ExportAgentRequest(request)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.export_agent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ agent.ExportAgentResponse,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+ def restore_agent(
+ self,
+ request: agent.RestoreAgentRequest = None,
+ *,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Restores the specified agent from a binary file.
+ Replaces the current agent with a new one. Note that all
+ existing resources in agent (e.g. intents, entity types,
+ flows) will be removed.
+
+ Args:
+ request (:class:`~.agent.RestoreAgentRequest`):
+ The request object. The request message for
+ [Agents.RestoreAgent][google.cloud.dialogflow.cx.v3.Agents.RestoreAgent].
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.empty.Empty``: A generic empty message that
+ you can re-use to avoid defining duplicated empty
+ messages in your APIs. A typical example is to use it as
+ the request or the response type of an API method. For
+ instance:
+
+ ::
+
+ service Foo {
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ }
+
+ The JSON representation for ``Empty`` is empty JSON
+ object ``{}``.
+
+ """
+ # Create or coerce a protobuf request object.
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a agent.RestoreAgentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, agent.RestoreAgentRequest):
+ request = agent.RestoreAgentRequest(request)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.restore_agent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ empty.Empty,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("AgentsClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/pagers.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/pagers.py
new file mode 100644
index 000000000000..f5fceec51a30
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/pagers.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
+
+from google.cloud.dialogflowcx_v3.types import agent
+
+
+class ListAgentsPager:
+ """A pager for iterating through ``list_agents`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.agent.ListAgentsResponse` object, and
+ provides an ``__iter__`` method to iterate through its
+ ``agents`` field.
+
+ If there are more pages, the ``__iter__`` method will make additional
+ ``ListAgents`` requests and continue to iterate
+ through the ``agents`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.agent.ListAgentsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., agent.ListAgentsResponse],
+ request: agent.ListAgentsRequest,
+ response: agent.ListAgentsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.agent.ListAgentsRequest`):
+ The initial request object.
+ response (:class:`~.agent.ListAgentsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = agent.ListAgentsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ def pages(self) -> Iterable[agent.ListAgentsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __iter__(self) -> Iterable[agent.Agent]:
+ for page in self.pages:
+ yield from page.agents
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class ListAgentsAsyncPager:
+ """A pager for iterating through ``list_agents`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.agent.ListAgentsResponse` object, and
+ provides an ``__aiter__`` method to iterate through its
+ ``agents`` field.
+
+ If there are more pages, the ``__aiter__`` method will make additional
+ ``ListAgents`` requests and continue to iterate
+ through the ``agents`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.agent.ListAgentsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., Awaitable[agent.ListAgentsResponse]],
+ request: agent.ListAgentsRequest,
+ response: agent.ListAgentsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.agent.ListAgentsRequest`):
+ The initial request object.
+ response (:class:`~.agent.ListAgentsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = agent.ListAgentsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ async def pages(self) -> AsyncIterable[agent.ListAgentsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = await self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __aiter__(self) -> AsyncIterable[agent.Agent]:
+ async def async_generator():
+ async for page in self.pages:
+ for response in page.agents:
+ yield response
+
+ return async_generator()
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py
new file mode 100644
index 000000000000..a87abc01deae
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/__init__.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from typing import Dict, Type
+
+from .base import AgentsTransport
+from .grpc import AgentsGrpcTransport
+from .grpc_asyncio import AgentsGrpcAsyncIOTransport
+
+
+# Compile a registry of transports.
+_transport_registry = OrderedDict() # type: Dict[str, Type[AgentsTransport]]
+_transport_registry["grpc"] = AgentsGrpcTransport
+_transport_registry["grpc_asyncio"] = AgentsGrpcAsyncIOTransport
+
+
+__all__ = (
+ "AgentsTransport",
+ "AgentsGrpcTransport",
+ "AgentsGrpcAsyncIOTransport",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/base.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/base.py
new file mode 100644
index 000000000000..c8f8d07732ac
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/base.py
@@ -0,0 +1,210 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 abc
+import typing
+import pkg_resources
+
+from google import auth # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google.auth import credentials # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import agent
+from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+class AgentsTransport(abc.ABC):
+ """Abstract transport class for Agents."""
+
+ AUTH_SCOPES = (
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/dialogflow",
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: typing.Optional[str] = None,
+ scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
+ quota_project_id: typing.Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ **kwargs,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scope (Optional[Sequence[str]]): A list of scopes.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+ """
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
+ if ":" not in host:
+ host += ":443"
+ self._host = host
+
+ # If no credentials are provided, then determine the appropriate
+ # defaults.
+ if credentials and credentials_file:
+ raise exceptions.DuplicateCredentialArgs(
+ "'credentials_file' and 'credentials' are mutually exclusive"
+ )
+
+ if credentials_file is not None:
+ credentials, _ = auth.load_credentials_from_file(
+ credentials_file, scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ elif credentials is None:
+ credentials, _ = auth.default(
+ scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ # Save the credentials.
+ self._credentials = credentials
+
+ # Lifted into its own function so it can be stubbed out during tests.
+ self._prep_wrapped_messages(client_info)
+
+ def _prep_wrapped_messages(self, client_info):
+ # Precompute the wrapped methods.
+ self._wrapped_methods = {
+ self.list_agents: gapic_v1.method.wrap_method(
+ self.list_agents, default_timeout=None, client_info=client_info,
+ ),
+ self.get_agent: gapic_v1.method.wrap_method(
+ self.get_agent, default_timeout=None, client_info=client_info,
+ ),
+ self.create_agent: gapic_v1.method.wrap_method(
+ self.create_agent, default_timeout=None, client_info=client_info,
+ ),
+ self.update_agent: gapic_v1.method.wrap_method(
+ self.update_agent, default_timeout=None, client_info=client_info,
+ ),
+ self.delete_agent: gapic_v1.method.wrap_method(
+ self.delete_agent, default_timeout=None, client_info=client_info,
+ ),
+ self.export_agent: gapic_v1.method.wrap_method(
+ self.export_agent, default_timeout=None, client_info=client_info,
+ ),
+ self.restore_agent: gapic_v1.method.wrap_method(
+ self.restore_agent, default_timeout=None, client_info=client_info,
+ ),
+ }
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsClient:
+ """Return the client designed to process long-running operations."""
+ raise NotImplementedError()
+
+ @property
+ def list_agents(
+ self,
+ ) -> typing.Callable[
+ [agent.ListAgentsRequest],
+ typing.Union[
+ agent.ListAgentsResponse, typing.Awaitable[agent.ListAgentsResponse]
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def get_agent(
+ self,
+ ) -> typing.Callable[
+ [agent.GetAgentRequest],
+ typing.Union[agent.Agent, typing.Awaitable[agent.Agent]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def create_agent(
+ self,
+ ) -> typing.Callable[
+ [gcdc_agent.CreateAgentRequest],
+ typing.Union[gcdc_agent.Agent, typing.Awaitable[gcdc_agent.Agent]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def update_agent(
+ self,
+ ) -> typing.Callable[
+ [gcdc_agent.UpdateAgentRequest],
+ typing.Union[gcdc_agent.Agent, typing.Awaitable[gcdc_agent.Agent]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def delete_agent(
+ self,
+ ) -> typing.Callable[
+ [agent.DeleteAgentRequest],
+ typing.Union[empty.Empty, typing.Awaitable[empty.Empty]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def export_agent(
+ self,
+ ) -> typing.Callable[
+ [agent.ExportAgentRequest],
+ typing.Union[operations.Operation, typing.Awaitable[operations.Operation]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def restore_agent(
+ self,
+ ) -> typing.Callable[
+ [agent.RestoreAgentRequest],
+ typing.Union[operations.Operation, typing.Awaitable[operations.Operation]],
+ ]:
+ raise NotImplementedError()
+
+
+__all__ = ("AgentsTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py
new file mode 100644
index 000000000000..bbf096192511
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/grpc.py
@@ -0,0 +1,435 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import grpc_helpers # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import agent
+from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import AgentsTransport, DEFAULT_CLIENT_INFO
+
+
+class AgentsGrpcTransport(AgentsTransport):
+ """gRPC backend transport for Agents.
+
+ Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _stubs: Dict[str, Callable]
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Sequence[str] = None,
+ channel: grpc.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id: Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
+ ignored if ``channel`` is provided.
+ channel (Optional[grpc.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ self._stubs = {} # type: Dict[str, Callable]
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> grpc.Channel:
+ """Create and return a gRPC channel object.
+ Args:
+ address (Optionsl[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ grpc.Channel: A gRPC channel object.
+
+ Raises:
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ @property
+ def grpc_channel(self) -> grpc.Channel:
+ """Return the channel designed to connect to this service.
+ """
+ return self._grpc_channel
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsClient:
+ """Create the client designed to process long-running operations.
+
+ 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.
+ if "operations_client" not in self.__dict__:
+ self.__dict__["operations_client"] = operations_v1.OperationsClient(
+ self.grpc_channel
+ )
+
+ # Return the client from cache.
+ return self.__dict__["operations_client"]
+
+ @property
+ def list_agents(
+ self,
+ ) -> Callable[[agent.ListAgentsRequest], agent.ListAgentsResponse]:
+ r"""Return a callable for the list agents method over gRPC.
+
+ Returns the list of all agents in the specified
+ location.
+
+ Returns:
+ Callable[[~.ListAgentsRequest],
+ ~.ListAgentsResponse]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_agents" not in self._stubs:
+ self._stubs["list_agents"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/ListAgents",
+ request_serializer=agent.ListAgentsRequest.serialize,
+ response_deserializer=agent.ListAgentsResponse.deserialize,
+ )
+ return self._stubs["list_agents"]
+
+ @property
+ def get_agent(self) -> Callable[[agent.GetAgentRequest], agent.Agent]:
+ r"""Return a callable for the get agent method over gRPC.
+
+ Retrieves the specified agent.
+
+ Returns:
+ Callable[[~.GetAgentRequest],
+ ~.Agent]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_agent" not in self._stubs:
+ self._stubs["get_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/GetAgent",
+ request_serializer=agent.GetAgentRequest.serialize,
+ response_deserializer=agent.Agent.deserialize,
+ )
+ return self._stubs["get_agent"]
+
+ @property
+ def create_agent(
+ self,
+ ) -> Callable[[gcdc_agent.CreateAgentRequest], gcdc_agent.Agent]:
+ r"""Return a callable for the create agent method over gRPC.
+
+ Creates an agent in the specified location.
+
+ Returns:
+ Callable[[~.CreateAgentRequest],
+ ~.Agent]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_agent" not in self._stubs:
+ self._stubs["create_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/CreateAgent",
+ request_serializer=gcdc_agent.CreateAgentRequest.serialize,
+ response_deserializer=gcdc_agent.Agent.deserialize,
+ )
+ return self._stubs["create_agent"]
+
+ @property
+ def update_agent(
+ self,
+ ) -> Callable[[gcdc_agent.UpdateAgentRequest], gcdc_agent.Agent]:
+ r"""Return a callable for the update agent method over gRPC.
+
+ Updates the specified agent.
+
+ Returns:
+ Callable[[~.UpdateAgentRequest],
+ ~.Agent]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_agent" not in self._stubs:
+ self._stubs["update_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/UpdateAgent",
+ request_serializer=gcdc_agent.UpdateAgentRequest.serialize,
+ response_deserializer=gcdc_agent.Agent.deserialize,
+ )
+ return self._stubs["update_agent"]
+
+ @property
+ def delete_agent(self) -> Callable[[agent.DeleteAgentRequest], empty.Empty]:
+ r"""Return a callable for the delete agent method over gRPC.
+
+ Deletes the specified agent.
+
+ Returns:
+ Callable[[~.DeleteAgentRequest],
+ ~.Empty]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_agent" not in self._stubs:
+ self._stubs["delete_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/DeleteAgent",
+ request_serializer=agent.DeleteAgentRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_agent"]
+
+ @property
+ def export_agent(
+ self,
+ ) -> Callable[[agent.ExportAgentRequest], operations.Operation]:
+ r"""Return a callable for the export agent method over gRPC.
+
+ Exports the specified agent to a binary file.
+
+ Returns:
+ Callable[[~.ExportAgentRequest],
+ ~.Operation]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "export_agent" not in self._stubs:
+ self._stubs["export_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/ExportAgent",
+ request_serializer=agent.ExportAgentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["export_agent"]
+
+ @property
+ def restore_agent(
+ self,
+ ) -> Callable[[agent.RestoreAgentRequest], operations.Operation]:
+ r"""Return a callable for the restore agent method over gRPC.
+
+ Restores the specified agent from a binary file.
+ Replaces the current agent with a new one. Note that all
+ existing resources in agent (e.g. intents, entity types,
+ flows) will be removed.
+
+ Returns:
+ Callable[[~.RestoreAgentRequest],
+ ~.Operation]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "restore_agent" not in self._stubs:
+ self._stubs["restore_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/RestoreAgent",
+ request_serializer=agent.RestoreAgentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["restore_agent"]
+
+
+__all__ = ("AgentsGrpcTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py
new file mode 100644
index 000000000000..8c5b8e485c31
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/agents/transports/grpc_asyncio.py
@@ -0,0 +1,441 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import grpc_helpers_async # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+from grpc.experimental import aio # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import agent
+from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import AgentsTransport, DEFAULT_CLIENT_INFO
+from .grpc import AgentsGrpcTransport
+
+
+class AgentsGrpcAsyncIOTransport(AgentsTransport):
+ """gRPC AsyncIO backend transport for Agents.
+
+ Service for managing [Agents][google.cloud.dialogflow.cx.v3.Agent].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _grpc_channel: aio.Channel
+ _stubs: Dict[str, Callable] = {}
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> aio.Channel:
+ """Create and return a gRPC AsyncIO channel object.
+ Args:
+ address (Optional[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ aio.Channel: A gRPC AsyncIO channel object.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers_async.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: aio.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id=None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ channel (Optional[aio.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ self._stubs = {}
+
+ @property
+ def grpc_channel(self) -> aio.Channel:
+ """Create the channel designed to connect to this service.
+
+ This property caches on the instance; repeated calls return
+ the same channel.
+ """
+ # Return the channel from cache.
+ return self._grpc_channel
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsAsyncClient:
+ """Create the client designed to process long-running operations.
+
+ 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.
+ if "operations_client" not in self.__dict__:
+ self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ self.grpc_channel
+ )
+
+ # Return the client from cache.
+ return self.__dict__["operations_client"]
+
+ @property
+ def list_agents(
+ self,
+ ) -> Callable[[agent.ListAgentsRequest], Awaitable[agent.ListAgentsResponse]]:
+ r"""Return a callable for the list agents method over gRPC.
+
+ Returns the list of all agents in the specified
+ location.
+
+ Returns:
+ Callable[[~.ListAgentsRequest],
+ Awaitable[~.ListAgentsResponse]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_agents" not in self._stubs:
+ self._stubs["list_agents"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/ListAgents",
+ request_serializer=agent.ListAgentsRequest.serialize,
+ response_deserializer=agent.ListAgentsResponse.deserialize,
+ )
+ return self._stubs["list_agents"]
+
+ @property
+ def get_agent(self) -> Callable[[agent.GetAgentRequest], Awaitable[agent.Agent]]:
+ r"""Return a callable for the get agent method over gRPC.
+
+ Retrieves the specified agent.
+
+ Returns:
+ Callable[[~.GetAgentRequest],
+ Awaitable[~.Agent]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_agent" not in self._stubs:
+ self._stubs["get_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/GetAgent",
+ request_serializer=agent.GetAgentRequest.serialize,
+ response_deserializer=agent.Agent.deserialize,
+ )
+ return self._stubs["get_agent"]
+
+ @property
+ def create_agent(
+ self,
+ ) -> Callable[[gcdc_agent.CreateAgentRequest], Awaitable[gcdc_agent.Agent]]:
+ r"""Return a callable for the create agent method over gRPC.
+
+ Creates an agent in the specified location.
+
+ Returns:
+ Callable[[~.CreateAgentRequest],
+ Awaitable[~.Agent]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_agent" not in self._stubs:
+ self._stubs["create_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/CreateAgent",
+ request_serializer=gcdc_agent.CreateAgentRequest.serialize,
+ response_deserializer=gcdc_agent.Agent.deserialize,
+ )
+ return self._stubs["create_agent"]
+
+ @property
+ def update_agent(
+ self,
+ ) -> Callable[[gcdc_agent.UpdateAgentRequest], Awaitable[gcdc_agent.Agent]]:
+ r"""Return a callable for the update agent method over gRPC.
+
+ Updates the specified agent.
+
+ Returns:
+ Callable[[~.UpdateAgentRequest],
+ Awaitable[~.Agent]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_agent" not in self._stubs:
+ self._stubs["update_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/UpdateAgent",
+ request_serializer=gcdc_agent.UpdateAgentRequest.serialize,
+ response_deserializer=gcdc_agent.Agent.deserialize,
+ )
+ return self._stubs["update_agent"]
+
+ @property
+ def delete_agent(
+ self,
+ ) -> Callable[[agent.DeleteAgentRequest], Awaitable[empty.Empty]]:
+ r"""Return a callable for the delete agent method over gRPC.
+
+ Deletes the specified agent.
+
+ Returns:
+ Callable[[~.DeleteAgentRequest],
+ Awaitable[~.Empty]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_agent" not in self._stubs:
+ self._stubs["delete_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/DeleteAgent",
+ request_serializer=agent.DeleteAgentRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_agent"]
+
+ @property
+ def export_agent(
+ self,
+ ) -> Callable[[agent.ExportAgentRequest], Awaitable[operations.Operation]]:
+ r"""Return a callable for the export agent method over gRPC.
+
+ Exports the specified agent to a binary file.
+
+ Returns:
+ Callable[[~.ExportAgentRequest],
+ Awaitable[~.Operation]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "export_agent" not in self._stubs:
+ self._stubs["export_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/ExportAgent",
+ request_serializer=agent.ExportAgentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["export_agent"]
+
+ @property
+ def restore_agent(
+ self,
+ ) -> Callable[[agent.RestoreAgentRequest], Awaitable[operations.Operation]]:
+ r"""Return a callable for the restore agent method over gRPC.
+
+ Restores the specified agent from a binary file.
+ Replaces the current agent with a new one. Note that all
+ existing resources in agent (e.g. intents, entity types,
+ flows) will be removed.
+
+ Returns:
+ Callable[[~.RestoreAgentRequest],
+ Awaitable[~.Operation]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "restore_agent" not in self._stubs:
+ self._stubs["restore_agent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Agents/RestoreAgent",
+ request_serializer=agent.RestoreAgentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["restore_agent"]
+
+
+__all__ = ("AgentsGrpcAsyncIOTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py
new file mode 100644
index 000000000000..f52849c66789
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from .client import EntityTypesClient
+from .async_client import EntityTypesAsyncClient
+
+__all__ = (
+ "EntityTypesClient",
+ "EntityTypesAsyncClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py
new file mode 100644
index 000000000000..3397af5ba562
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/async_client.py
@@ -0,0 +1,635 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.cloud.dialogflowcx_v3.services.entity_types import pagers
+from google.cloud.dialogflowcx_v3.types import entity_type
+from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+
+from .transports.base import EntityTypesTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import EntityTypesGrpcAsyncIOTransport
+from .client import EntityTypesClient
+
+
+class EntityTypesAsyncClient:
+ """Service for managing
+ [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType].
+ """
+
+ _client: EntityTypesClient
+
+ DEFAULT_ENDPOINT = EntityTypesClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = EntityTypesClient.DEFAULT_MTLS_ENDPOINT
+
+ entity_type_path = staticmethod(EntityTypesClient.entity_type_path)
+ parse_entity_type_path = staticmethod(EntityTypesClient.parse_entity_type_path)
+
+ common_billing_account_path = staticmethod(
+ EntityTypesClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ EntityTypesClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(EntityTypesClient.common_folder_path)
+ parse_common_folder_path = staticmethod(EntityTypesClient.parse_common_folder_path)
+
+ common_organization_path = staticmethod(EntityTypesClient.common_organization_path)
+ parse_common_organization_path = staticmethod(
+ EntityTypesClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(EntityTypesClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ EntityTypesClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(EntityTypesClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ EntityTypesClient.parse_common_location_path
+ )
+
+ from_service_account_file = EntityTypesClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> EntityTypesTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ EntityTypesTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(EntityTypesClient).get_transport_class, type(EntityTypesClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, EntityTypesTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the entity types client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.EntityTypesTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = EntityTypesClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def list_entity_types(
+ self,
+ request: entity_type.ListEntityTypesRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListEntityTypesAsyncPager:
+ r"""Returns the list of all entity types in the specified
+ agent.
+
+ Args:
+ request (:class:`~.entity_type.ListEntityTypesRequest`):
+ The request object. The request message for
+ [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes].
+ parent (:class:`str`):
+ Required. The agent to list all entity types for.
+ Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListEntityTypesAsyncPager:
+ The response message for
+ [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = entity_type.ListEntityTypesRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_entity_types,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListEntityTypesAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_entity_type(
+ self,
+ request: entity_type.GetEntityTypeRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> entity_type.EntityType:
+ r"""Retrieves the specified entity type.
+
+ Args:
+ request (:class:`~.entity_type.GetEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.GetEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.GetEntityType].
+ name (:class:`str`):
+ Required. The name of the entity type. Format:
+ ``projects//locations//agents//entityTypes/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.entity_type.EntityType:
+ Entities are extracted from user input and represent
+ parameters that are meaningful to your application. For
+ example, a date range, a proper name such as a
+ geographic location or landmark, and so on. Entities
+ represent actionable data for your application.
+
+ When you define an entity, you can also include synonyms
+ that all map to that entity. For example, "soft drink",
+ "soda", "pop", and so on.
+
+ There are three types of entities:
+
+ - **System** - entities that are defined by the
+ Dialogflow API for common data types such as date,
+ time, currency, and so on. A system entity is
+ represented by the ``EntityType`` type.
+
+ - **Custom** - entities that are defined by you that
+ represent actionable data that is meaningful to your
+ application. For example, you could define a
+ ``pizza.sauce`` entity for red or white pizza sauce,
+ a ``pizza.cheese`` entity for the different types of
+ cheese on a pizza, a ``pizza.topping`` entity for
+ different toppings, and so on. A custom entity is
+ represented by the ``EntityType`` type.
+
+ - **User** - entities that are built for an individual
+ user such as favorites, preferences, playlists, and
+ so on. A user entity is represented by the
+ [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType]
+ type.
+
+ For more information about entity types, see the
+ `Dialogflow
+ documentation `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = entity_type.GetEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_entity_type,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def create_entity_type(
+ self,
+ request: gcdc_entity_type.CreateEntityTypeRequest = None,
+ *,
+ parent: str = None,
+ entity_type: gcdc_entity_type.EntityType = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_entity_type.EntityType:
+ r"""Creates an entity type in the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_entity_type.CreateEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.CreateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.CreateEntityType].
+ parent (:class:`str`):
+ Required. The agent to create a entity type for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ entity_type (:class:`~.gcdc_entity_type.EntityType`):
+ Required. The entity type to create.
+ This corresponds to the ``entity_type`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_entity_type.EntityType:
+ Entities are extracted from user input and represent
+ parameters that are meaningful to your application. For
+ example, a date range, a proper name such as a
+ geographic location or landmark, and so on. Entities
+ represent actionable data for your application.
+
+ When you define an entity, you can also include synonyms
+ that all map to that entity. For example, "soft drink",
+ "soda", "pop", and so on.
+
+ There are three types of entities:
+
+ - **System** - entities that are defined by the
+ Dialogflow API for common data types such as date,
+ time, currency, and so on. A system entity is
+ represented by the ``EntityType`` type.
+
+ - **Custom** - entities that are defined by you that
+ represent actionable data that is meaningful to your
+ application. For example, you could define a
+ ``pizza.sauce`` entity for red or white pizza sauce,
+ a ``pizza.cheese`` entity for the different types of
+ cheese on a pizza, a ``pizza.topping`` entity for
+ different toppings, and so on. A custom entity is
+ represented by the ``EntityType`` type.
+
+ - **User** - entities that are built for an individual
+ user such as favorites, preferences, playlists, and
+ so on. A user entity is represented by the
+ [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType]
+ type.
+
+ For more information about entity types, see the
+ `Dialogflow
+ documentation `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_entity_type.CreateEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if entity_type is not None:
+ request.entity_type = entity_type
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_entity_type,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def update_entity_type(
+ self,
+ request: gcdc_entity_type.UpdateEntityTypeRequest = None,
+ *,
+ entity_type: gcdc_entity_type.EntityType = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_entity_type.EntityType:
+ r"""Updates the specified entity type.
+
+ Args:
+ request (:class:`~.gcdc_entity_type.UpdateEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType].
+ entity_type (:class:`~.gcdc_entity_type.EntityType`):
+ Required. The entity type to update.
+ This corresponds to the ``entity_type`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ The mask to control which fields get
+ updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_entity_type.EntityType:
+ Entities are extracted from user input and represent
+ parameters that are meaningful to your application. For
+ example, a date range, a proper name such as a
+ geographic location or landmark, and so on. Entities
+ represent actionable data for your application.
+
+ When you define an entity, you can also include synonyms
+ that all map to that entity. For example, "soft drink",
+ "soda", "pop", and so on.
+
+ There are three types of entities:
+
+ - **System** - entities that are defined by the
+ Dialogflow API for common data types such as date,
+ time, currency, and so on. A system entity is
+ represented by the ``EntityType`` type.
+
+ - **Custom** - entities that are defined by you that
+ represent actionable data that is meaningful to your
+ application. For example, you could define a
+ ``pizza.sauce`` entity for red or white pizza sauce,
+ a ``pizza.cheese`` entity for the different types of
+ cheese on a pizza, a ``pizza.topping`` entity for
+ different toppings, and so on. A custom entity is
+ represented by the ``EntityType`` type.
+
+ - **User** - entities that are built for an individual
+ user such as favorites, preferences, playlists, and
+ so on. A user entity is represented by the
+ [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType]
+ type.
+
+ For more information about entity types, see the
+ `Dialogflow
+ documentation `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_entity_type.UpdateEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if entity_type is not None:
+ request.entity_type = entity_type
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_entity_type,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("entity_type.name", request.entity_type.name),)
+ ),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def delete_entity_type(
+ self,
+ request: entity_type.DeleteEntityTypeRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified entity type.
+
+ Args:
+ request (:class:`~.entity_type.DeleteEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.DeleteEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.DeleteEntityType].
+ name (:class:`str`):
+ Required. The name of the entity type to delete. Format:
+ ``projects//locations//agents//entityTypes/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = entity_type.DeleteEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.delete_entity_type,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("EntityTypesAsyncClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/client.py
new file mode 100644
index 000000000000..aacf1f5ef61b
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/client.py
@@ -0,0 +1,835 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from distutils import util
+import os
+import re
+from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
+import pkg_resources
+
+from google.api_core import client_options as client_options_lib # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport import mtls # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+from google.auth.exceptions import MutualTLSChannelError # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.cloud.dialogflowcx_v3.services.entity_types import pagers
+from google.cloud.dialogflowcx_v3.types import entity_type
+from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+
+from .transports.base import EntityTypesTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc import EntityTypesGrpcTransport
+from .transports.grpc_asyncio import EntityTypesGrpcAsyncIOTransport
+
+
+class EntityTypesClientMeta(type):
+ """Metaclass for the EntityTypes client.
+
+ This provides class-level methods for building and retrieving
+ support objects (e.g. transport) without polluting the client instance
+ objects.
+ """
+
+ _transport_registry = OrderedDict() # type: Dict[str, Type[EntityTypesTransport]]
+ _transport_registry["grpc"] = EntityTypesGrpcTransport
+ _transport_registry["grpc_asyncio"] = EntityTypesGrpcAsyncIOTransport
+
+ def get_transport_class(cls, label: str = None,) -> Type[EntityTypesTransport]:
+ """Return an appropriate transport class.
+
+ Args:
+ label: The name of the desired transport. If none is
+ provided, then the first transport in the registry is used.
+
+ Returns:
+ The transport class to use.
+ """
+ # If a specific transport is requested, return that one.
+ if label:
+ return cls._transport_registry[label]
+
+ # No transport is requested; return the default (that is, the first one
+ # in the dictionary).
+ return next(iter(cls._transport_registry.values()))
+
+
+class EntityTypesClient(metaclass=EntityTypesClientMeta):
+ """Service for managing
+ [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType].
+ """
+
+ @staticmethod
+ def _get_default_mtls_endpoint(api_endpoint):
+ """Convert api endpoint to mTLS endpoint.
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
+ Args:
+ api_endpoint (Optional[str]): the api endpoint to convert.
+ Returns:
+ str: converted mTLS api endpoint.
+ """
+ if not api_endpoint:
+ return api_endpoint
+
+ mtls_endpoint_re = re.compile(
+ r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?"
+ )
+
+ m = mtls_endpoint_re.match(api_endpoint)
+ name, mtls, sandbox, googledomain = m.groups()
+ if mtls or not googledomain:
+ return api_endpoint
+
+ if sandbox:
+ return api_endpoint.replace(
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
+ )
+
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
+
+ DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
+ DEFAULT_ENDPOINT
+ )
+
+ @classmethod
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ file.
+
+ Args:
+ filename (str): The path to the service account private key json
+ file.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ {@api.name}: The constructed client.
+ """
+ credentials = service_account.Credentials.from_service_account_file(filename)
+ kwargs["credentials"] = credentials
+ return cls(*args, **kwargs)
+
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> EntityTypesTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ EntityTypesTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def entity_type_path(
+ project: str, location: str, agent: str, entity_type: str,
+ ) -> str:
+ """Return a fully-qualified entity_type string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(
+ project=project, location=location, agent=agent, entity_type=entity_type,
+ )
+
+ @staticmethod
+ def parse_entity_type_path(path: str) -> Dict[str, str]:
+ """Parse a entity_type path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[credentials.Credentials] = None,
+ transport: Union[str, EntityTypesTransport, None] = None,
+ client_options: Optional[client_options_lib.ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the entity types client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.EntityTypesTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (client_options_lib.ClientOptions): Custom options for the
+ client. It won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+ if isinstance(client_options, dict):
+ client_options = client_options_lib.from_dict(client_options)
+ if client_options is None:
+ client_options = client_options_lib.ClientOptions()
+
+ # Create SSL credentials for mutual TLS if needed.
+ use_client_cert = bool(
+ util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
+ )
+
+ ssl_credentials = None
+ is_mtls = False
+ if use_client_cert:
+ if client_options.client_cert_source:
+ import grpc # type: ignore
+
+ cert, key = client_options.client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ is_mtls = True
+ else:
+ creds = SslCredentials()
+ is_mtls = creds.is_mtls
+ ssl_credentials = creds.ssl_credentials if is_mtls else 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":
+ api_endpoint = (
+ self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
+ )
+ else:
+ raise MutualTLSChannelError(
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ )
+
+ # 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:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its credentials directly."
+ )
+ if client_options.scopes:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its scopes directly."
+ )
+ self._transport = transport
+ else:
+ Transport = type(self).get_transport_class(transport)
+ self._transport = Transport(
+ credentials=credentials,
+ credentials_file=client_options.credentials_file,
+ host=api_endpoint,
+ scopes=client_options.scopes,
+ ssl_channel_credentials=ssl_credentials,
+ quota_project_id=client_options.quota_project_id,
+ client_info=client_info,
+ )
+
+ def list_entity_types(
+ self,
+ request: entity_type.ListEntityTypesRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListEntityTypesPager:
+ r"""Returns the list of all entity types in the specified
+ agent.
+
+ Args:
+ request (:class:`~.entity_type.ListEntityTypesRequest`):
+ The request object. The request message for
+ [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes].
+ parent (:class:`str`):
+ Required. The agent to list all entity types for.
+ Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListEntityTypesPager:
+ The response message for
+ [EntityTypes.ListEntityTypes][google.cloud.dialogflow.cx.v3.EntityTypes.ListEntityTypes].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a entity_type.ListEntityTypesRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, entity_type.ListEntityTypesRequest):
+ request = entity_type.ListEntityTypesRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.list_entity_types]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.ListEntityTypesPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_entity_type(
+ self,
+ request: entity_type.GetEntityTypeRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> entity_type.EntityType:
+ r"""Retrieves the specified entity type.
+
+ Args:
+ request (:class:`~.entity_type.GetEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.GetEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.GetEntityType].
+ name (:class:`str`):
+ Required. The name of the entity type. Format:
+ ``projects//locations//agents//entityTypes/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.entity_type.EntityType:
+ Entities are extracted from user input and represent
+ parameters that are meaningful to your application. For
+ example, a date range, a proper name such as a
+ geographic location or landmark, and so on. Entities
+ represent actionable data for your application.
+
+ When you define an entity, you can also include synonyms
+ that all map to that entity. For example, "soft drink",
+ "soda", "pop", and so on.
+
+ There are three types of entities:
+
+ - **System** - entities that are defined by the
+ Dialogflow API for common data types such as date,
+ time, currency, and so on. A system entity is
+ represented by the ``EntityType`` type.
+
+ - **Custom** - entities that are defined by you that
+ represent actionable data that is meaningful to your
+ application. For example, you could define a
+ ``pizza.sauce`` entity for red or white pizza sauce,
+ a ``pizza.cheese`` entity for the different types of
+ cheese on a pizza, a ``pizza.topping`` entity for
+ different toppings, and so on. A custom entity is
+ represented by the ``EntityType`` type.
+
+ - **User** - entities that are built for an individual
+ user such as favorites, preferences, playlists, and
+ so on. A user entity is represented by the
+ [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType]
+ type.
+
+ For more information about entity types, see the
+ `Dialogflow
+ documentation `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a entity_type.GetEntityTypeRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, entity_type.GetEntityTypeRequest):
+ request = entity_type.GetEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_entity_type]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def create_entity_type(
+ self,
+ request: gcdc_entity_type.CreateEntityTypeRequest = None,
+ *,
+ parent: str = None,
+ entity_type: gcdc_entity_type.EntityType = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_entity_type.EntityType:
+ r"""Creates an entity type in the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_entity_type.CreateEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.CreateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.CreateEntityType].
+ parent (:class:`str`):
+ Required. The agent to create a entity type for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ entity_type (:class:`~.gcdc_entity_type.EntityType`):
+ Required. The entity type to create.
+ This corresponds to the ``entity_type`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_entity_type.EntityType:
+ Entities are extracted from user input and represent
+ parameters that are meaningful to your application. For
+ example, a date range, a proper name such as a
+ geographic location or landmark, and so on. Entities
+ represent actionable data for your application.
+
+ When you define an entity, you can also include synonyms
+ that all map to that entity. For example, "soft drink",
+ "soda", "pop", and so on.
+
+ There are three types of entities:
+
+ - **System** - entities that are defined by the
+ Dialogflow API for common data types such as date,
+ time, currency, and so on. A system entity is
+ represented by the ``EntityType`` type.
+
+ - **Custom** - entities that are defined by you that
+ represent actionable data that is meaningful to your
+ application. For example, you could define a
+ ``pizza.sauce`` entity for red or white pizza sauce,
+ a ``pizza.cheese`` entity for the different types of
+ cheese on a pizza, a ``pizza.topping`` entity for
+ different toppings, and so on. A custom entity is
+ represented by the ``EntityType`` type.
+
+ - **User** - entities that are built for an individual
+ user such as favorites, preferences, playlists, and
+ so on. A user entity is represented by the
+ [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType]
+ type.
+
+ For more information about entity types, see the
+ `Dialogflow
+ documentation `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_entity_type.CreateEntityTypeRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_entity_type.CreateEntityTypeRequest):
+ request = gcdc_entity_type.CreateEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if entity_type is not None:
+ request.entity_type = entity_type
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_entity_type]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def update_entity_type(
+ self,
+ request: gcdc_entity_type.UpdateEntityTypeRequest = None,
+ *,
+ entity_type: gcdc_entity_type.EntityType = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_entity_type.EntityType:
+ r"""Updates the specified entity type.
+
+ Args:
+ request (:class:`~.gcdc_entity_type.UpdateEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.UpdateEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.UpdateEntityType].
+ entity_type (:class:`~.gcdc_entity_type.EntityType`):
+ Required. The entity type to update.
+ This corresponds to the ``entity_type`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ The mask to control which fields get
+ updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_entity_type.EntityType:
+ Entities are extracted from user input and represent
+ parameters that are meaningful to your application. For
+ example, a date range, a proper name such as a
+ geographic location or landmark, and so on. Entities
+ represent actionable data for your application.
+
+ When you define an entity, you can also include synonyms
+ that all map to that entity. For example, "soft drink",
+ "soda", "pop", and so on.
+
+ There are three types of entities:
+
+ - **System** - entities that are defined by the
+ Dialogflow API for common data types such as date,
+ time, currency, and so on. A system entity is
+ represented by the ``EntityType`` type.
+
+ - **Custom** - entities that are defined by you that
+ represent actionable data that is meaningful to your
+ application. For example, you could define a
+ ``pizza.sauce`` entity for red or white pizza sauce,
+ a ``pizza.cheese`` entity for the different types of
+ cheese on a pizza, a ``pizza.topping`` entity for
+ different toppings, and so on. A custom entity is
+ represented by the ``EntityType`` type.
+
+ - **User** - entities that are built for an individual
+ user such as favorites, preferences, playlists, and
+ so on. A user entity is represented by the
+ [SessionEntityType][google.cloud.dialogflow.cx.v3.SessionEntityType]
+ type.
+
+ For more information about entity types, see the
+ `Dialogflow
+ documentation `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_entity_type.UpdateEntityTypeRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_entity_type.UpdateEntityTypeRequest):
+ request = gcdc_entity_type.UpdateEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if entity_type is not None:
+ request.entity_type = entity_type
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_entity_type]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("entity_type.name", request.entity_type.name),)
+ ),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def delete_entity_type(
+ self,
+ request: entity_type.DeleteEntityTypeRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified entity type.
+
+ Args:
+ request (:class:`~.entity_type.DeleteEntityTypeRequest`):
+ The request object. The request message for
+ [EntityTypes.DeleteEntityType][google.cloud.dialogflow.cx.v3.EntityTypes.DeleteEntityType].
+ name (:class:`str`):
+ Required. The name of the entity type to delete. Format:
+ ``projects//locations//agents//entityTypes/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a entity_type.DeleteEntityTypeRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, entity_type.DeleteEntityTypeRequest):
+ request = entity_type.DeleteEntityTypeRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.delete_entity_type]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("EntityTypesClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py
new file mode 100644
index 000000000000..edafb73d6dc4
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/pagers.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
+
+from google.cloud.dialogflowcx_v3.types import entity_type
+
+
+class ListEntityTypesPager:
+ """A pager for iterating through ``list_entity_types`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.entity_type.ListEntityTypesResponse` object, and
+ provides an ``__iter__`` method to iterate through its
+ ``entity_types`` field.
+
+ If there are more pages, the ``__iter__`` method will make additional
+ ``ListEntityTypes`` requests and continue to iterate
+ through the ``entity_types`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.entity_type.ListEntityTypesResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., entity_type.ListEntityTypesResponse],
+ request: entity_type.ListEntityTypesRequest,
+ response: entity_type.ListEntityTypesResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.entity_type.ListEntityTypesRequest`):
+ The initial request object.
+ response (:class:`~.entity_type.ListEntityTypesResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = entity_type.ListEntityTypesRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ def pages(self) -> Iterable[entity_type.ListEntityTypesResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __iter__(self) -> Iterable[entity_type.EntityType]:
+ for page in self.pages:
+ yield from page.entity_types
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class ListEntityTypesAsyncPager:
+ """A pager for iterating through ``list_entity_types`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.entity_type.ListEntityTypesResponse` object, and
+ provides an ``__aiter__`` method to iterate through its
+ ``entity_types`` field.
+
+ If there are more pages, the ``__aiter__`` method will make additional
+ ``ListEntityTypes`` requests and continue to iterate
+ through the ``entity_types`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.entity_type.ListEntityTypesResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., Awaitable[entity_type.ListEntityTypesResponse]],
+ request: entity_type.ListEntityTypesRequest,
+ response: entity_type.ListEntityTypesResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.entity_type.ListEntityTypesRequest`):
+ The initial request object.
+ response (:class:`~.entity_type.ListEntityTypesResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = entity_type.ListEntityTypesRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ async def pages(self) -> AsyncIterable[entity_type.ListEntityTypesResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = await self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __aiter__(self) -> AsyncIterable[entity_type.EntityType]:
+ async def async_generator():
+ async for page in self.pages:
+ for response in page.entity_types:
+ yield response
+
+ return async_generator()
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py
new file mode 100644
index 000000000000..bd6250cb0634
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/__init__.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from typing import Dict, Type
+
+from .base import EntityTypesTransport
+from .grpc import EntityTypesGrpcTransport
+from .grpc_asyncio import EntityTypesGrpcAsyncIOTransport
+
+
+# Compile a registry of transports.
+_transport_registry = OrderedDict() # type: Dict[str, Type[EntityTypesTransport]]
+_transport_registry["grpc"] = EntityTypesGrpcTransport
+_transport_registry["grpc_asyncio"] = EntityTypesGrpcAsyncIOTransport
+
+
+__all__ = (
+ "EntityTypesTransport",
+ "EntityTypesGrpcTransport",
+ "EntityTypesGrpcAsyncIOTransport",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py
new file mode 100644
index 000000000000..e3faf53a783a
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/base.py
@@ -0,0 +1,184 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 abc
+import typing
+import pkg_resources
+
+from google import auth # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import entity_type
+from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+class EntityTypesTransport(abc.ABC):
+ """Abstract transport class for EntityTypes."""
+
+ AUTH_SCOPES = (
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/dialogflow",
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: typing.Optional[str] = None,
+ scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
+ quota_project_id: typing.Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ **kwargs,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scope (Optional[Sequence[str]]): A list of scopes.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+ """
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
+ if ":" not in host:
+ host += ":443"
+ self._host = host
+
+ # If no credentials are provided, then determine the appropriate
+ # defaults.
+ if credentials and credentials_file:
+ raise exceptions.DuplicateCredentialArgs(
+ "'credentials_file' and 'credentials' are mutually exclusive"
+ )
+
+ if credentials_file is not None:
+ credentials, _ = auth.load_credentials_from_file(
+ credentials_file, scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ elif credentials is None:
+ credentials, _ = auth.default(
+ scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ # Save the credentials.
+ self._credentials = credentials
+
+ # Lifted into its own function so it can be stubbed out during tests.
+ self._prep_wrapped_messages(client_info)
+
+ def _prep_wrapped_messages(self, client_info):
+ # Precompute the wrapped methods.
+ self._wrapped_methods = {
+ self.list_entity_types: gapic_v1.method.wrap_method(
+ self.list_entity_types, default_timeout=None, client_info=client_info,
+ ),
+ self.get_entity_type: gapic_v1.method.wrap_method(
+ self.get_entity_type, default_timeout=None, client_info=client_info,
+ ),
+ self.create_entity_type: gapic_v1.method.wrap_method(
+ self.create_entity_type, default_timeout=None, client_info=client_info,
+ ),
+ self.update_entity_type: gapic_v1.method.wrap_method(
+ self.update_entity_type, default_timeout=None, client_info=client_info,
+ ),
+ self.delete_entity_type: gapic_v1.method.wrap_method(
+ self.delete_entity_type, default_timeout=None, client_info=client_info,
+ ),
+ }
+
+ @property
+ def list_entity_types(
+ self,
+ ) -> typing.Callable[
+ [entity_type.ListEntityTypesRequest],
+ typing.Union[
+ entity_type.ListEntityTypesResponse,
+ typing.Awaitable[entity_type.ListEntityTypesResponse],
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def get_entity_type(
+ self,
+ ) -> typing.Callable[
+ [entity_type.GetEntityTypeRequest],
+ typing.Union[entity_type.EntityType, typing.Awaitable[entity_type.EntityType]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def create_entity_type(
+ self,
+ ) -> typing.Callable[
+ [gcdc_entity_type.CreateEntityTypeRequest],
+ typing.Union[
+ gcdc_entity_type.EntityType, typing.Awaitable[gcdc_entity_type.EntityType]
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def update_entity_type(
+ self,
+ ) -> typing.Callable[
+ [gcdc_entity_type.UpdateEntityTypeRequest],
+ typing.Union[
+ gcdc_entity_type.EntityType, typing.Awaitable[gcdc_entity_type.EntityType]
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def delete_entity_type(
+ self,
+ ) -> typing.Callable[
+ [entity_type.DeleteEntityTypeRequest],
+ typing.Union[empty.Empty, typing.Awaitable[empty.Empty]],
+ ]:
+ raise NotImplementedError()
+
+
+__all__ = ("EntityTypesTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py
new file mode 100644
index 000000000000..490b6fac9e52
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc.py
@@ -0,0 +1,373 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import grpc_helpers # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import entity_type
+from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import EntityTypesTransport, DEFAULT_CLIENT_INFO
+
+
+class EntityTypesGrpcTransport(EntityTypesTransport):
+ """gRPC backend transport for EntityTypes.
+
+ Service for managing
+ [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _stubs: Dict[str, Callable]
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Sequence[str] = None,
+ channel: grpc.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id: Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
+ ignored if ``channel`` is provided.
+ channel (Optional[grpc.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ self._stubs = {} # type: Dict[str, Callable]
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> grpc.Channel:
+ """Create and return a gRPC channel object.
+ Args:
+ address (Optionsl[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ grpc.Channel: A gRPC channel object.
+
+ Raises:
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ @property
+ def grpc_channel(self) -> grpc.Channel:
+ """Return the channel designed to connect to this service.
+ """
+ return self._grpc_channel
+
+ @property
+ def list_entity_types(
+ self,
+ ) -> Callable[
+ [entity_type.ListEntityTypesRequest], entity_type.ListEntityTypesResponse
+ ]:
+ r"""Return a callable for the list entity types method over gRPC.
+
+ Returns the list of all entity types in the specified
+ agent.
+
+ Returns:
+ Callable[[~.ListEntityTypesRequest],
+ ~.ListEntityTypesResponse]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_entity_types" not in self._stubs:
+ self._stubs["list_entity_types"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/ListEntityTypes",
+ request_serializer=entity_type.ListEntityTypesRequest.serialize,
+ response_deserializer=entity_type.ListEntityTypesResponse.deserialize,
+ )
+ return self._stubs["list_entity_types"]
+
+ @property
+ def get_entity_type(
+ self,
+ ) -> Callable[[entity_type.GetEntityTypeRequest], entity_type.EntityType]:
+ r"""Return a callable for the get entity type method over gRPC.
+
+ Retrieves the specified entity type.
+
+ Returns:
+ Callable[[~.GetEntityTypeRequest],
+ ~.EntityType]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_entity_type" not in self._stubs:
+ self._stubs["get_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/GetEntityType",
+ request_serializer=entity_type.GetEntityTypeRequest.serialize,
+ response_deserializer=entity_type.EntityType.deserialize,
+ )
+ return self._stubs["get_entity_type"]
+
+ @property
+ def create_entity_type(
+ self,
+ ) -> Callable[
+ [gcdc_entity_type.CreateEntityTypeRequest], gcdc_entity_type.EntityType
+ ]:
+ r"""Return a callable for the create entity type method over gRPC.
+
+ Creates an entity type in the specified agent.
+
+ Returns:
+ Callable[[~.CreateEntityTypeRequest],
+ ~.EntityType]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_entity_type" not in self._stubs:
+ self._stubs["create_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/CreateEntityType",
+ request_serializer=gcdc_entity_type.CreateEntityTypeRequest.serialize,
+ response_deserializer=gcdc_entity_type.EntityType.deserialize,
+ )
+ return self._stubs["create_entity_type"]
+
+ @property
+ def update_entity_type(
+ self,
+ ) -> Callable[
+ [gcdc_entity_type.UpdateEntityTypeRequest], gcdc_entity_type.EntityType
+ ]:
+ r"""Return a callable for the update entity type method over gRPC.
+
+ Updates the specified entity type.
+
+ Returns:
+ Callable[[~.UpdateEntityTypeRequest],
+ ~.EntityType]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_entity_type" not in self._stubs:
+ self._stubs["update_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/UpdateEntityType",
+ request_serializer=gcdc_entity_type.UpdateEntityTypeRequest.serialize,
+ response_deserializer=gcdc_entity_type.EntityType.deserialize,
+ )
+ return self._stubs["update_entity_type"]
+
+ @property
+ def delete_entity_type(
+ self,
+ ) -> Callable[[entity_type.DeleteEntityTypeRequest], empty.Empty]:
+ r"""Return a callable for the delete entity type method over gRPC.
+
+ Deletes the specified entity type.
+
+ Returns:
+ Callable[[~.DeleteEntityTypeRequest],
+ ~.Empty]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_entity_type" not in self._stubs:
+ self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/DeleteEntityType",
+ request_serializer=entity_type.DeleteEntityTypeRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_entity_type"]
+
+
+__all__ = ("EntityTypesGrpcTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py
new file mode 100644
index 000000000000..5729cc642c74
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/entity_types/transports/grpc_asyncio.py
@@ -0,0 +1,382 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import grpc_helpers_async # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+from grpc.experimental import aio # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import entity_type
+from google.cloud.dialogflowcx_v3.types import entity_type as gcdc_entity_type
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import EntityTypesTransport, DEFAULT_CLIENT_INFO
+from .grpc import EntityTypesGrpcTransport
+
+
+class EntityTypesGrpcAsyncIOTransport(EntityTypesTransport):
+ """gRPC AsyncIO backend transport for EntityTypes.
+
+ Service for managing
+ [EntityTypes][google.cloud.dialogflow.cx.v3.EntityType].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _grpc_channel: aio.Channel
+ _stubs: Dict[str, Callable] = {}
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> aio.Channel:
+ """Create and return a gRPC AsyncIO channel object.
+ Args:
+ address (Optional[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ aio.Channel: A gRPC AsyncIO channel object.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers_async.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: aio.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id=None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ channel (Optional[aio.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ self._stubs = {}
+
+ @property
+ def grpc_channel(self) -> aio.Channel:
+ """Create the channel designed to connect to this service.
+
+ This property caches on the instance; repeated calls return
+ the same channel.
+ """
+ # Return the channel from cache.
+ return self._grpc_channel
+
+ @property
+ def list_entity_types(
+ self,
+ ) -> Callable[
+ [entity_type.ListEntityTypesRequest],
+ Awaitable[entity_type.ListEntityTypesResponse],
+ ]:
+ r"""Return a callable for the list entity types method over gRPC.
+
+ Returns the list of all entity types in the specified
+ agent.
+
+ Returns:
+ Callable[[~.ListEntityTypesRequest],
+ Awaitable[~.ListEntityTypesResponse]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_entity_types" not in self._stubs:
+ self._stubs["list_entity_types"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/ListEntityTypes",
+ request_serializer=entity_type.ListEntityTypesRequest.serialize,
+ response_deserializer=entity_type.ListEntityTypesResponse.deserialize,
+ )
+ return self._stubs["list_entity_types"]
+
+ @property
+ def get_entity_type(
+ self,
+ ) -> Callable[
+ [entity_type.GetEntityTypeRequest], Awaitable[entity_type.EntityType]
+ ]:
+ r"""Return a callable for the get entity type method over gRPC.
+
+ Retrieves the specified entity type.
+
+ Returns:
+ Callable[[~.GetEntityTypeRequest],
+ Awaitable[~.EntityType]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_entity_type" not in self._stubs:
+ self._stubs["get_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/GetEntityType",
+ request_serializer=entity_type.GetEntityTypeRequest.serialize,
+ response_deserializer=entity_type.EntityType.deserialize,
+ )
+ return self._stubs["get_entity_type"]
+
+ @property
+ def create_entity_type(
+ self,
+ ) -> Callable[
+ [gcdc_entity_type.CreateEntityTypeRequest],
+ Awaitable[gcdc_entity_type.EntityType],
+ ]:
+ r"""Return a callable for the create entity type method over gRPC.
+
+ Creates an entity type in the specified agent.
+
+ Returns:
+ Callable[[~.CreateEntityTypeRequest],
+ Awaitable[~.EntityType]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_entity_type" not in self._stubs:
+ self._stubs["create_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/CreateEntityType",
+ request_serializer=gcdc_entity_type.CreateEntityTypeRequest.serialize,
+ response_deserializer=gcdc_entity_type.EntityType.deserialize,
+ )
+ return self._stubs["create_entity_type"]
+
+ @property
+ def update_entity_type(
+ self,
+ ) -> Callable[
+ [gcdc_entity_type.UpdateEntityTypeRequest],
+ Awaitable[gcdc_entity_type.EntityType],
+ ]:
+ r"""Return a callable for the update entity type method over gRPC.
+
+ Updates the specified entity type.
+
+ Returns:
+ Callable[[~.UpdateEntityTypeRequest],
+ Awaitable[~.EntityType]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_entity_type" not in self._stubs:
+ self._stubs["update_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/UpdateEntityType",
+ request_serializer=gcdc_entity_type.UpdateEntityTypeRequest.serialize,
+ response_deserializer=gcdc_entity_type.EntityType.deserialize,
+ )
+ return self._stubs["update_entity_type"]
+
+ @property
+ def delete_entity_type(
+ self,
+ ) -> Callable[[entity_type.DeleteEntityTypeRequest], Awaitable[empty.Empty]]:
+ r"""Return a callable for the delete entity type method over gRPC.
+
+ Deletes the specified entity type.
+
+ Returns:
+ Callable[[~.DeleteEntityTypeRequest],
+ Awaitable[~.Empty]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_entity_type" not in self._stubs:
+ self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.EntityTypes/DeleteEntityType",
+ request_serializer=entity_type.DeleteEntityTypeRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_entity_type"]
+
+
+__all__ = ("EntityTypesGrpcAsyncIOTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/__init__.py
new file mode 100644
index 000000000000..a67f2316d94a
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from .client import EnvironmentsClient
+from .async_client import EnvironmentsAsyncClient
+
+__all__ = (
+ "EnvironmentsClient",
+ "EnvironmentsAsyncClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/async_client.py
new file mode 100644
index 000000000000..edf94a12c506
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/async_client.py
@@ -0,0 +1,692 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.dialogflowcx_v3.services.environments import pagers
+from google.cloud.dialogflowcx_v3.types import environment
+from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import struct_pb2 as struct # type: ignore
+from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+
+from .transports.base import EnvironmentsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport
+from .client import EnvironmentsClient
+
+
+class EnvironmentsAsyncClient:
+ """Service for managing
+ [Environments][google.cloud.dialogflow.cx.v3.Environment].
+ """
+
+ _client: EnvironmentsClient
+
+ DEFAULT_ENDPOINT = EnvironmentsClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = EnvironmentsClient.DEFAULT_MTLS_ENDPOINT
+
+ environment_path = staticmethod(EnvironmentsClient.environment_path)
+ parse_environment_path = staticmethod(EnvironmentsClient.parse_environment_path)
+ version_path = staticmethod(EnvironmentsClient.version_path)
+ parse_version_path = staticmethod(EnvironmentsClient.parse_version_path)
+
+ common_billing_account_path = staticmethod(
+ EnvironmentsClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ EnvironmentsClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(EnvironmentsClient.common_folder_path)
+ parse_common_folder_path = staticmethod(EnvironmentsClient.parse_common_folder_path)
+
+ common_organization_path = staticmethod(EnvironmentsClient.common_organization_path)
+ parse_common_organization_path = staticmethod(
+ EnvironmentsClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(EnvironmentsClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ EnvironmentsClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(EnvironmentsClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ EnvironmentsClient.parse_common_location_path
+ )
+
+ from_service_account_file = EnvironmentsClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> EnvironmentsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ EnvironmentsTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(EnvironmentsClient).get_transport_class, type(EnvironmentsClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, EnvironmentsTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the environments client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.EnvironmentsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = EnvironmentsClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def list_environments(
+ self,
+ request: environment.ListEnvironmentsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListEnvironmentsAsyncPager:
+ r"""Returns the list of all environments in the specified
+ [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Args:
+ request (:class:`~.environment.ListEnvironmentsRequest`):
+ The request object. The request message for
+ [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments].
+ parent (:class:`str`):
+ Required. The
+ [Agent][google.cloud.dialogflow.cx.v3.Agent] to list all
+ environments for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListEnvironmentsAsyncPager:
+ The response message for
+ [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = environment.ListEnvironmentsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_environments,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListEnvironmentsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_environment(
+ self,
+ request: environment.GetEnvironmentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> environment.Environment:
+ r"""Retrieves the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.environment.GetEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3.Environments.GetEnvironment].
+ name (:class:`str`):
+ Required. The name of the
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+ Format:
+ ``projects//locations//agents//environments/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.environment.Environment:
+ Represents an environment for an
+ agent. You can create multiple versions
+ of your agent and publish them to
+ separate environments. When you edit an
+ agent, you are editing the draft agent.
+ At any point, you can save the draft
+ agent as an agent version, which is an
+ immutable snapshot of your agent. When
+ you save the draft agent, it is
+ published to the default environment.
+ When you create agent versions, you can
+ publish them to custom environments. You
+ can create a variety of custom
+ environments for testing, development,
+ production, etc.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = environment.GetEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_environment,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def create_environment(
+ self,
+ request: gcdc_environment.CreateEnvironmentRequest = None,
+ *,
+ parent: str = None,
+ environment: gcdc_environment.Environment = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Creates an
+ [Environment][google.cloud.dialogflow.cx.v3.Environment] in the
+ specified [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Args:
+ request (:class:`~.gcdc_environment.CreateEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3.Environments.CreateEnvironment].
+ parent (:class:`str`):
+ Required. The
+ [Agent][google.cloud.dialogflow.cx.v3.Agent] to create
+ an
+ [Environment][google.cloud.dialogflow.cx.v3.Environment]
+ for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ environment (:class:`~.gcdc_environment.Environment`):
+ Required. The environment to create.
+ This corresponds to the ``environment`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.gcdc_environment.Environment``: Represents an
+ environment for an agent. You can create multiple
+ versions of your agent and publish them to separate
+ environments. When you edit an agent, you are editing
+ the draft agent. At any point, you can save the draft
+ agent as an agent version, which is an immutable
+ snapshot of your agent. When you save the draft agent,
+ it is published to the default environment. When you
+ create agent versions, you can publish them to custom
+ environments. You can create a variety of custom
+ environments for testing, development, production, etc.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_environment.CreateEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if environment is not None:
+ request.environment = environment
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_environment,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ gcdc_environment.Environment,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def update_environment(
+ self,
+ request: gcdc_environment.UpdateEnvironmentRequest = None,
+ *,
+ environment: gcdc_environment.Environment = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Updates the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.gcdc_environment.UpdateEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3.Environments.UpdateEnvironment].
+ environment (:class:`~.gcdc_environment.Environment`):
+ Required. The environment to update.
+ This corresponds to the ``environment`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ Required. The mask to control which
+ fields get updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.gcdc_environment.Environment``: Represents an
+ environment for an agent. You can create multiple
+ versions of your agent and publish them to separate
+ environments. When you edit an agent, you are editing
+ the draft agent. At any point, you can save the draft
+ agent as an agent version, which is an immutable
+ snapshot of your agent. When you save the draft agent,
+ it is published to the default environment. When you
+ create agent versions, you can publish them to custom
+ environments. You can create a variety of custom
+ environments for testing, development, production, etc.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_environment.UpdateEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if environment is not None:
+ request.environment = environment
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_environment,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("environment.name", request.environment.name),)
+ ),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ gcdc_environment.Environment,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def delete_environment(
+ self,
+ request: environment.DeleteEnvironmentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.environment.DeleteEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3.Environments.DeleteEnvironment].
+ name (:class:`str`):
+ Required. The name of the
+ [Environment][google.cloud.dialogflow.cx.v3.Environment]
+ to delete. Format:
+ ``projects//locations//agents//environments/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = environment.DeleteEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.delete_environment,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ async def lookup_environment_history(
+ self,
+ request: environment.LookupEnvironmentHistoryRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.LookupEnvironmentHistoryAsyncPager:
+ r"""Looks up the history of the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.environment.LookupEnvironmentHistoryRequest`):
+ The request object. The request message for
+ [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory].
+ name (:class:`str`):
+ Required. Resource name of the environment to look up
+ the history for. Format:
+ ``projects//locations//agents//environments/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.LookupEnvironmentHistoryAsyncPager:
+ The response message for
+ [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = environment.LookupEnvironmentHistoryRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.lookup_environment_history,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.LookupEnvironmentHistoryAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("EnvironmentsAsyncClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/client.py
new file mode 100644
index 000000000000..5acfe0b3d8de
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/client.py
@@ -0,0 +1,911 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from distutils import util
+import os
+import re
+from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
+import pkg_resources
+
+from google.api_core import client_options as client_options_lib # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport import mtls # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+from google.auth.exceptions import MutualTLSChannelError # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.dialogflowcx_v3.services.environments import pagers
+from google.cloud.dialogflowcx_v3.types import environment
+from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import struct_pb2 as struct # type: ignore
+from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+
+from .transports.base import EnvironmentsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc import EnvironmentsGrpcTransport
+from .transports.grpc_asyncio import EnvironmentsGrpcAsyncIOTransport
+
+
+class EnvironmentsClientMeta(type):
+ """Metaclass for the Environments client.
+
+ This provides class-level methods for building and retrieving
+ support objects (e.g. transport) without polluting the client instance
+ objects.
+ """
+
+ _transport_registry = OrderedDict() # type: Dict[str, Type[EnvironmentsTransport]]
+ _transport_registry["grpc"] = EnvironmentsGrpcTransport
+ _transport_registry["grpc_asyncio"] = EnvironmentsGrpcAsyncIOTransport
+
+ def get_transport_class(cls, label: str = None,) -> Type[EnvironmentsTransport]:
+ """Return an appropriate transport class.
+
+ Args:
+ label: The name of the desired transport. If none is
+ provided, then the first transport in the registry is used.
+
+ Returns:
+ The transport class to use.
+ """
+ # If a specific transport is requested, return that one.
+ if label:
+ return cls._transport_registry[label]
+
+ # No transport is requested; return the default (that is, the first one
+ # in the dictionary).
+ return next(iter(cls._transport_registry.values()))
+
+
+class EnvironmentsClient(metaclass=EnvironmentsClientMeta):
+ """Service for managing
+ [Environments][google.cloud.dialogflow.cx.v3.Environment].
+ """
+
+ @staticmethod
+ def _get_default_mtls_endpoint(api_endpoint):
+ """Convert api endpoint to mTLS endpoint.
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
+ Args:
+ api_endpoint (Optional[str]): the api endpoint to convert.
+ Returns:
+ str: converted mTLS api endpoint.
+ """
+ if not api_endpoint:
+ return api_endpoint
+
+ mtls_endpoint_re = re.compile(
+ r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?"
+ )
+
+ m = mtls_endpoint_re.match(api_endpoint)
+ name, mtls, sandbox, googledomain = m.groups()
+ if mtls or not googledomain:
+ return api_endpoint
+
+ if sandbox:
+ return api_endpoint.replace(
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
+ )
+
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
+
+ DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
+ DEFAULT_ENDPOINT
+ )
+
+ @classmethod
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ file.
+
+ Args:
+ filename (str): The path to the service account private key json
+ file.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ {@api.name}: The constructed client.
+ """
+ credentials = service_account.Credentials.from_service_account_file(filename)
+ kwargs["credentials"] = credentials
+ return cls(*args, **kwargs)
+
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> EnvironmentsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ EnvironmentsTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def environment_path(
+ project: str, location: str, agent: str, environment: str,
+ ) -> str:
+ """Return a fully-qualified environment string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}".format(
+ project=project, location=location, agent=agent, environment=environment,
+ )
+
+ @staticmethod
+ def parse_environment_path(path: str) -> Dict[str, str]:
+ """Parse a environment path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/environments/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def version_path(
+ project: str, location: str, agent: str, flow: str, version: str,
+ ) -> str:
+ """Return a fully-qualified version string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(
+ project=project, location=location, agent=agent, flow=flow, version=version,
+ )
+
+ @staticmethod
+ def parse_version_path(path: str) -> Dict[str, str]:
+ """Parse a version path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/versions/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[credentials.Credentials] = None,
+ transport: Union[str, EnvironmentsTransport, None] = None,
+ client_options: Optional[client_options_lib.ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the environments client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.EnvironmentsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (client_options_lib.ClientOptions): Custom options for the
+ client. It won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+ if isinstance(client_options, dict):
+ client_options = client_options_lib.from_dict(client_options)
+ if client_options is None:
+ client_options = client_options_lib.ClientOptions()
+
+ # Create SSL credentials for mutual TLS if needed.
+ use_client_cert = bool(
+ util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
+ )
+
+ ssl_credentials = None
+ is_mtls = False
+ if use_client_cert:
+ if client_options.client_cert_source:
+ import grpc # type: ignore
+
+ cert, key = client_options.client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ is_mtls = True
+ else:
+ creds = SslCredentials()
+ is_mtls = creds.is_mtls
+ ssl_credentials = creds.ssl_credentials if is_mtls else 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":
+ api_endpoint = (
+ self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
+ )
+ else:
+ raise MutualTLSChannelError(
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ )
+
+ # 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:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its credentials directly."
+ )
+ if client_options.scopes:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its scopes directly."
+ )
+ self._transport = transport
+ else:
+ Transport = type(self).get_transport_class(transport)
+ self._transport = Transport(
+ credentials=credentials,
+ credentials_file=client_options.credentials_file,
+ host=api_endpoint,
+ scopes=client_options.scopes,
+ ssl_channel_credentials=ssl_credentials,
+ quota_project_id=client_options.quota_project_id,
+ client_info=client_info,
+ )
+
+ def list_environments(
+ self,
+ request: environment.ListEnvironmentsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListEnvironmentsPager:
+ r"""Returns the list of all environments in the specified
+ [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Args:
+ request (:class:`~.environment.ListEnvironmentsRequest`):
+ The request object. The request message for
+ [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments].
+ parent (:class:`str`):
+ Required. The
+ [Agent][google.cloud.dialogflow.cx.v3.Agent] to list all
+ environments for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListEnvironmentsPager:
+ The response message for
+ [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3.Environments.ListEnvironments].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a environment.ListEnvironmentsRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, environment.ListEnvironmentsRequest):
+ request = environment.ListEnvironmentsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.list_environments]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.ListEnvironmentsPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_environment(
+ self,
+ request: environment.GetEnvironmentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> environment.Environment:
+ r"""Retrieves the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.environment.GetEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3.Environments.GetEnvironment].
+ name (:class:`str`):
+ Required. The name of the
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+ Format:
+ ``projects//locations//agents//environments/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.environment.Environment:
+ Represents an environment for an
+ agent. You can create multiple versions
+ of your agent and publish them to
+ separate environments. When you edit an
+ agent, you are editing the draft agent.
+ At any point, you can save the draft
+ agent as an agent version, which is an
+ immutable snapshot of your agent. When
+ you save the draft agent, it is
+ published to the default environment.
+ When you create agent versions, you can
+ publish them to custom environments. You
+ can create a variety of custom
+ environments for testing, development,
+ production, etc.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a environment.GetEnvironmentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, environment.GetEnvironmentRequest):
+ request = environment.GetEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_environment]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def create_environment(
+ self,
+ request: gcdc_environment.CreateEnvironmentRequest = None,
+ *,
+ parent: str = None,
+ environment: gcdc_environment.Environment = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Creates an
+ [Environment][google.cloud.dialogflow.cx.v3.Environment] in the
+ specified [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Args:
+ request (:class:`~.gcdc_environment.CreateEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3.Environments.CreateEnvironment].
+ parent (:class:`str`):
+ Required. The
+ [Agent][google.cloud.dialogflow.cx.v3.Agent] to create
+ an
+ [Environment][google.cloud.dialogflow.cx.v3.Environment]
+ for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ environment (:class:`~.gcdc_environment.Environment`):
+ Required. The environment to create.
+ This corresponds to the ``environment`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.gcdc_environment.Environment``: Represents an
+ environment for an agent. You can create multiple
+ versions of your agent and publish them to separate
+ environments. When you edit an agent, you are editing
+ the draft agent. At any point, you can save the draft
+ agent as an agent version, which is an immutable
+ snapshot of your agent. When you save the draft agent,
+ it is published to the default environment. When you
+ create agent versions, you can publish them to custom
+ environments. You can create a variety of custom
+ environments for testing, development, production, etc.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_environment.CreateEnvironmentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_environment.CreateEnvironmentRequest):
+ request = gcdc_environment.CreateEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if environment is not None:
+ request.environment = environment
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_environment]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ gcdc_environment.Environment,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+ def update_environment(
+ self,
+ request: gcdc_environment.UpdateEnvironmentRequest = None,
+ *,
+ environment: gcdc_environment.Environment = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Updates the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.gcdc_environment.UpdateEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3.Environments.UpdateEnvironment].
+ environment (:class:`~.gcdc_environment.Environment`):
+ Required. The environment to update.
+ This corresponds to the ``environment`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ Required. The mask to control which
+ fields get updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.gcdc_environment.Environment``: Represents an
+ environment for an agent. You can create multiple
+ versions of your agent and publish them to separate
+ environments. When you edit an agent, you are editing
+ the draft agent. At any point, you can save the draft
+ agent as an agent version, which is an immutable
+ snapshot of your agent. When you save the draft agent,
+ it is published to the default environment. When you
+ create agent versions, you can publish them to custom
+ environments. You can create a variety of custom
+ environments for testing, development, production, etc.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_environment.UpdateEnvironmentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_environment.UpdateEnvironmentRequest):
+ request = gcdc_environment.UpdateEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if environment is not None:
+ request.environment = environment
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_environment]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("environment.name", request.environment.name),)
+ ),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ gcdc_environment.Environment,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+ def delete_environment(
+ self,
+ request: environment.DeleteEnvironmentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.environment.DeleteEnvironmentRequest`):
+ The request object. The request message for
+ [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3.Environments.DeleteEnvironment].
+ name (:class:`str`):
+ Required. The name of the
+ [Environment][google.cloud.dialogflow.cx.v3.Environment]
+ to delete. Format:
+ ``projects//locations//agents//environments/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a environment.DeleteEnvironmentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, environment.DeleteEnvironmentRequest):
+ request = environment.DeleteEnvironmentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.delete_environment]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ def lookup_environment_history(
+ self,
+ request: environment.LookupEnvironmentHistoryRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.LookupEnvironmentHistoryPager:
+ r"""Looks up the history of the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Args:
+ request (:class:`~.environment.LookupEnvironmentHistoryRequest`):
+ The request object. The request message for
+ [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory].
+ name (:class:`str`):
+ Required. Resource name of the environment to look up
+ the history for. Format:
+ ``projects//locations//agents//environments/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.LookupEnvironmentHistoryPager:
+ The response message for
+ [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3.Environments.LookupEnvironmentHistory].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a environment.LookupEnvironmentHistoryRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, environment.LookupEnvironmentHistoryRequest):
+ request = environment.LookupEnvironmentHistoryRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[
+ self._transport.lookup_environment_history
+ ]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.LookupEnvironmentHistoryPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("EnvironmentsClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/pagers.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/pagers.py
new file mode 100644
index 000000000000..ce8409a4c5d3
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/pagers.py
@@ -0,0 +1,278 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
+
+from google.cloud.dialogflowcx_v3.types import environment
+
+
+class ListEnvironmentsPager:
+ """A pager for iterating through ``list_environments`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.environment.ListEnvironmentsResponse` object, and
+ provides an ``__iter__`` method to iterate through its
+ ``environments`` field.
+
+ If there are more pages, the ``__iter__`` method will make additional
+ ``ListEnvironments`` requests and continue to iterate
+ through the ``environments`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.environment.ListEnvironmentsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., environment.ListEnvironmentsResponse],
+ request: environment.ListEnvironmentsRequest,
+ response: environment.ListEnvironmentsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.environment.ListEnvironmentsRequest`):
+ The initial request object.
+ response (:class:`~.environment.ListEnvironmentsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = environment.ListEnvironmentsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ def pages(self) -> Iterable[environment.ListEnvironmentsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __iter__(self) -> Iterable[environment.Environment]:
+ for page in self.pages:
+ yield from page.environments
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class ListEnvironmentsAsyncPager:
+ """A pager for iterating through ``list_environments`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.environment.ListEnvironmentsResponse` object, and
+ provides an ``__aiter__`` method to iterate through its
+ ``environments`` field.
+
+ If there are more pages, the ``__aiter__`` method will make additional
+ ``ListEnvironments`` requests and continue to iterate
+ through the ``environments`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.environment.ListEnvironmentsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., Awaitable[environment.ListEnvironmentsResponse]],
+ request: environment.ListEnvironmentsRequest,
+ response: environment.ListEnvironmentsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.environment.ListEnvironmentsRequest`):
+ The initial request object.
+ response (:class:`~.environment.ListEnvironmentsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = environment.ListEnvironmentsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ async def pages(self) -> AsyncIterable[environment.ListEnvironmentsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = await self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __aiter__(self) -> AsyncIterable[environment.Environment]:
+ async def async_generator():
+ async for page in self.pages:
+ for response in page.environments:
+ yield response
+
+ return async_generator()
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class LookupEnvironmentHistoryPager:
+ """A pager for iterating through ``lookup_environment_history`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.environment.LookupEnvironmentHistoryResponse` object, and
+ provides an ``__iter__`` method to iterate through its
+ ``environments`` field.
+
+ If there are more pages, the ``__iter__`` method will make additional
+ ``LookupEnvironmentHistory`` requests and continue to iterate
+ through the ``environments`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.environment.LookupEnvironmentHistoryResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., environment.LookupEnvironmentHistoryResponse],
+ request: environment.LookupEnvironmentHistoryRequest,
+ response: environment.LookupEnvironmentHistoryResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.environment.LookupEnvironmentHistoryRequest`):
+ The initial request object.
+ response (:class:`~.environment.LookupEnvironmentHistoryResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = environment.LookupEnvironmentHistoryRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ def pages(self) -> Iterable[environment.LookupEnvironmentHistoryResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __iter__(self) -> Iterable[environment.Environment]:
+ for page in self.pages:
+ yield from page.environments
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class LookupEnvironmentHistoryAsyncPager:
+ """A pager for iterating through ``lookup_environment_history`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.environment.LookupEnvironmentHistoryResponse` object, and
+ provides an ``__aiter__`` method to iterate through its
+ ``environments`` field.
+
+ If there are more pages, the ``__aiter__`` method will make additional
+ ``LookupEnvironmentHistory`` requests and continue to iterate
+ through the ``environments`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.environment.LookupEnvironmentHistoryResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., Awaitable[environment.LookupEnvironmentHistoryResponse]],
+ request: environment.LookupEnvironmentHistoryRequest,
+ response: environment.LookupEnvironmentHistoryResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.environment.LookupEnvironmentHistoryRequest`):
+ The initial request object.
+ response (:class:`~.environment.LookupEnvironmentHistoryResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = environment.LookupEnvironmentHistoryRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ async def pages(
+ self,
+ ) -> AsyncIterable[environment.LookupEnvironmentHistoryResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = await self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __aiter__(self) -> AsyncIterable[environment.Environment]:
+ async def async_generator():
+ async for page in self.pages:
+ for response in page.environments:
+ yield response
+
+ return async_generator()
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py
new file mode 100644
index 000000000000..14f04446cd7d
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/__init__.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from typing import Dict, Type
+
+from .base import EnvironmentsTransport
+from .grpc import EnvironmentsGrpcTransport
+from .grpc_asyncio import EnvironmentsGrpcAsyncIOTransport
+
+
+# Compile a registry of transports.
+_transport_registry = OrderedDict() # type: Dict[str, Type[EnvironmentsTransport]]
+_transport_registry["grpc"] = EnvironmentsGrpcTransport
+_transport_registry["grpc_asyncio"] = EnvironmentsGrpcAsyncIOTransport
+
+
+__all__ = (
+ "EnvironmentsTransport",
+ "EnvironmentsGrpcTransport",
+ "EnvironmentsGrpcAsyncIOTransport",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/base.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/base.py
new file mode 100644
index 000000000000..7f827332052b
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/base.py
@@ -0,0 +1,206 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 abc
+import typing
+import pkg_resources
+
+from google import auth # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google.auth import credentials # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import environment
+from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+class EnvironmentsTransport(abc.ABC):
+ """Abstract transport class for Environments."""
+
+ AUTH_SCOPES = (
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/dialogflow",
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: typing.Optional[str] = None,
+ scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
+ quota_project_id: typing.Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ **kwargs,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scope (Optional[Sequence[str]]): A list of scopes.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+ """
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
+ if ":" not in host:
+ host += ":443"
+ self._host = host
+
+ # If no credentials are provided, then determine the appropriate
+ # defaults.
+ if credentials and credentials_file:
+ raise exceptions.DuplicateCredentialArgs(
+ "'credentials_file' and 'credentials' are mutually exclusive"
+ )
+
+ if credentials_file is not None:
+ credentials, _ = auth.load_credentials_from_file(
+ credentials_file, scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ elif credentials is None:
+ credentials, _ = auth.default(
+ scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ # Save the credentials.
+ self._credentials = credentials
+
+ # Lifted into its own function so it can be stubbed out during tests.
+ self._prep_wrapped_messages(client_info)
+
+ def _prep_wrapped_messages(self, client_info):
+ # Precompute the wrapped methods.
+ self._wrapped_methods = {
+ self.list_environments: gapic_v1.method.wrap_method(
+ self.list_environments, default_timeout=None, client_info=client_info,
+ ),
+ self.get_environment: gapic_v1.method.wrap_method(
+ self.get_environment, default_timeout=None, client_info=client_info,
+ ),
+ self.create_environment: gapic_v1.method.wrap_method(
+ self.create_environment, default_timeout=None, client_info=client_info,
+ ),
+ self.update_environment: gapic_v1.method.wrap_method(
+ self.update_environment, default_timeout=None, client_info=client_info,
+ ),
+ self.delete_environment: gapic_v1.method.wrap_method(
+ self.delete_environment, default_timeout=None, client_info=client_info,
+ ),
+ self.lookup_environment_history: gapic_v1.method.wrap_method(
+ self.lookup_environment_history,
+ default_timeout=None,
+ client_info=client_info,
+ ),
+ }
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsClient:
+ """Return the client designed to process long-running operations."""
+ raise NotImplementedError()
+
+ @property
+ def list_environments(
+ self,
+ ) -> typing.Callable[
+ [environment.ListEnvironmentsRequest],
+ typing.Union[
+ environment.ListEnvironmentsResponse,
+ typing.Awaitable[environment.ListEnvironmentsResponse],
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def get_environment(
+ self,
+ ) -> typing.Callable[
+ [environment.GetEnvironmentRequest],
+ typing.Union[
+ environment.Environment, typing.Awaitable[environment.Environment]
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def create_environment(
+ self,
+ ) -> typing.Callable[
+ [gcdc_environment.CreateEnvironmentRequest],
+ typing.Union[operations.Operation, typing.Awaitable[operations.Operation]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def update_environment(
+ self,
+ ) -> typing.Callable[
+ [gcdc_environment.UpdateEnvironmentRequest],
+ typing.Union[operations.Operation, typing.Awaitable[operations.Operation]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def delete_environment(
+ self,
+ ) -> typing.Callable[
+ [environment.DeleteEnvironmentRequest],
+ typing.Union[empty.Empty, typing.Awaitable[empty.Empty]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def lookup_environment_history(
+ self,
+ ) -> typing.Callable[
+ [environment.LookupEnvironmentHistoryRequest],
+ typing.Union[
+ environment.LookupEnvironmentHistoryResponse,
+ typing.Awaitable[environment.LookupEnvironmentHistoryResponse],
+ ],
+ ]:
+ raise NotImplementedError()
+
+
+__all__ = ("EnvironmentsTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py
new file mode 100644
index 000000000000..3086e0475e41
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/grpc.py
@@ -0,0 +1,422 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import grpc_helpers # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import environment
+from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import EnvironmentsTransport, DEFAULT_CLIENT_INFO
+
+
+class EnvironmentsGrpcTransport(EnvironmentsTransport):
+ """gRPC backend transport for Environments.
+
+ Service for managing
+ [Environments][google.cloud.dialogflow.cx.v3.Environment].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _stubs: Dict[str, Callable]
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Sequence[str] = None,
+ channel: grpc.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id: Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
+ ignored if ``channel`` is provided.
+ channel (Optional[grpc.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ self._stubs = {} # type: Dict[str, Callable]
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> grpc.Channel:
+ """Create and return a gRPC channel object.
+ Args:
+ address (Optionsl[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ grpc.Channel: A gRPC channel object.
+
+ Raises:
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ @property
+ def grpc_channel(self) -> grpc.Channel:
+ """Return the channel designed to connect to this service.
+ """
+ return self._grpc_channel
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsClient:
+ """Create the client designed to process long-running operations.
+
+ 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.
+ if "operations_client" not in self.__dict__:
+ self.__dict__["operations_client"] = operations_v1.OperationsClient(
+ self.grpc_channel
+ )
+
+ # Return the client from cache.
+ return self.__dict__["operations_client"]
+
+ @property
+ def list_environments(
+ self,
+ ) -> Callable[
+ [environment.ListEnvironmentsRequest], environment.ListEnvironmentsResponse
+ ]:
+ r"""Return a callable for the list environments method over gRPC.
+
+ Returns the list of all environments in the specified
+ [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Returns:
+ Callable[[~.ListEnvironmentsRequest],
+ ~.ListEnvironmentsResponse]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_environments" not in self._stubs:
+ self._stubs["list_environments"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/ListEnvironments",
+ request_serializer=environment.ListEnvironmentsRequest.serialize,
+ response_deserializer=environment.ListEnvironmentsResponse.deserialize,
+ )
+ return self._stubs["list_environments"]
+
+ @property
+ def get_environment(
+ self,
+ ) -> Callable[[environment.GetEnvironmentRequest], environment.Environment]:
+ r"""Return a callable for the get environment method over gRPC.
+
+ Retrieves the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.GetEnvironmentRequest],
+ ~.Environment]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_environment" not in self._stubs:
+ self._stubs["get_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/GetEnvironment",
+ request_serializer=environment.GetEnvironmentRequest.serialize,
+ response_deserializer=environment.Environment.deserialize,
+ )
+ return self._stubs["get_environment"]
+
+ @property
+ def create_environment(
+ self,
+ ) -> Callable[[gcdc_environment.CreateEnvironmentRequest], operations.Operation]:
+ r"""Return a callable for the create environment method over gRPC.
+
+ Creates an
+ [Environment][google.cloud.dialogflow.cx.v3.Environment] in the
+ specified [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Returns:
+ Callable[[~.CreateEnvironmentRequest],
+ ~.Operation]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_environment" not in self._stubs:
+ self._stubs["create_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/CreateEnvironment",
+ request_serializer=gcdc_environment.CreateEnvironmentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["create_environment"]
+
+ @property
+ def update_environment(
+ self,
+ ) -> Callable[[gcdc_environment.UpdateEnvironmentRequest], operations.Operation]:
+ r"""Return a callable for the update environment method over gRPC.
+
+ Updates the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.UpdateEnvironmentRequest],
+ ~.Operation]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_environment" not in self._stubs:
+ self._stubs["update_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/UpdateEnvironment",
+ request_serializer=gcdc_environment.UpdateEnvironmentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["update_environment"]
+
+ @property
+ def delete_environment(
+ self,
+ ) -> Callable[[environment.DeleteEnvironmentRequest], empty.Empty]:
+ r"""Return a callable for the delete environment method over gRPC.
+
+ Deletes the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.DeleteEnvironmentRequest],
+ ~.Empty]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_environment" not in self._stubs:
+ self._stubs["delete_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/DeleteEnvironment",
+ request_serializer=environment.DeleteEnvironmentRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_environment"]
+
+ @property
+ def lookup_environment_history(
+ self,
+ ) -> Callable[
+ [environment.LookupEnvironmentHistoryRequest],
+ environment.LookupEnvironmentHistoryResponse,
+ ]:
+ r"""Return a callable for the lookup environment history method over gRPC.
+
+ Looks up the history of the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.LookupEnvironmentHistoryRequest],
+ ~.LookupEnvironmentHistoryResponse]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "lookup_environment_history" not in self._stubs:
+ self._stubs["lookup_environment_history"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/LookupEnvironmentHistory",
+ request_serializer=environment.LookupEnvironmentHistoryRequest.serialize,
+ response_deserializer=environment.LookupEnvironmentHistoryResponse.deserialize,
+ )
+ return self._stubs["lookup_environment_history"]
+
+
+__all__ = ("EnvironmentsGrpcTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py
new file mode 100644
index 000000000000..e6a2594f2134
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/environments/transports/grpc_asyncio.py
@@ -0,0 +1,433 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import grpc_helpers_async # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+from grpc.experimental import aio # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import environment
+from google.cloud.dialogflowcx_v3.types import environment as gcdc_environment
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import EnvironmentsTransport, DEFAULT_CLIENT_INFO
+from .grpc import EnvironmentsGrpcTransport
+
+
+class EnvironmentsGrpcAsyncIOTransport(EnvironmentsTransport):
+ """gRPC AsyncIO backend transport for Environments.
+
+ Service for managing
+ [Environments][google.cloud.dialogflow.cx.v3.Environment].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _grpc_channel: aio.Channel
+ _stubs: Dict[str, Callable] = {}
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> aio.Channel:
+ """Create and return a gRPC AsyncIO channel object.
+ Args:
+ address (Optional[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ aio.Channel: A gRPC AsyncIO channel object.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers_async.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: aio.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id=None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ channel (Optional[aio.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ self._stubs = {}
+
+ @property
+ def grpc_channel(self) -> aio.Channel:
+ """Create the channel designed to connect to this service.
+
+ This property caches on the instance; repeated calls return
+ the same channel.
+ """
+ # Return the channel from cache.
+ return self._grpc_channel
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsAsyncClient:
+ """Create the client designed to process long-running operations.
+
+ 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.
+ if "operations_client" not in self.__dict__:
+ self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ self.grpc_channel
+ )
+
+ # Return the client from cache.
+ return self.__dict__["operations_client"]
+
+ @property
+ def list_environments(
+ self,
+ ) -> Callable[
+ [environment.ListEnvironmentsRequest],
+ Awaitable[environment.ListEnvironmentsResponse],
+ ]:
+ r"""Return a callable for the list environments method over gRPC.
+
+ Returns the list of all environments in the specified
+ [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Returns:
+ Callable[[~.ListEnvironmentsRequest],
+ Awaitable[~.ListEnvironmentsResponse]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_environments" not in self._stubs:
+ self._stubs["list_environments"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/ListEnvironments",
+ request_serializer=environment.ListEnvironmentsRequest.serialize,
+ response_deserializer=environment.ListEnvironmentsResponse.deserialize,
+ )
+ return self._stubs["list_environments"]
+
+ @property
+ def get_environment(
+ self,
+ ) -> Callable[
+ [environment.GetEnvironmentRequest], Awaitable[environment.Environment]
+ ]:
+ r"""Return a callable for the get environment method over gRPC.
+
+ Retrieves the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.GetEnvironmentRequest],
+ Awaitable[~.Environment]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_environment" not in self._stubs:
+ self._stubs["get_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/GetEnvironment",
+ request_serializer=environment.GetEnvironmentRequest.serialize,
+ response_deserializer=environment.Environment.deserialize,
+ )
+ return self._stubs["get_environment"]
+
+ @property
+ def create_environment(
+ self,
+ ) -> Callable[
+ [gcdc_environment.CreateEnvironmentRequest], Awaitable[operations.Operation]
+ ]:
+ r"""Return a callable for the create environment method over gRPC.
+
+ Creates an
+ [Environment][google.cloud.dialogflow.cx.v3.Environment] in the
+ specified [Agent][google.cloud.dialogflow.cx.v3.Agent].
+
+ Returns:
+ Callable[[~.CreateEnvironmentRequest],
+ Awaitable[~.Operation]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_environment" not in self._stubs:
+ self._stubs["create_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/CreateEnvironment",
+ request_serializer=gcdc_environment.CreateEnvironmentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["create_environment"]
+
+ @property
+ def update_environment(
+ self,
+ ) -> Callable[
+ [gcdc_environment.UpdateEnvironmentRequest], Awaitable[operations.Operation]
+ ]:
+ r"""Return a callable for the update environment method over gRPC.
+
+ Updates the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.UpdateEnvironmentRequest],
+ Awaitable[~.Operation]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_environment" not in self._stubs:
+ self._stubs["update_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/UpdateEnvironment",
+ request_serializer=gcdc_environment.UpdateEnvironmentRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["update_environment"]
+
+ @property
+ def delete_environment(
+ self,
+ ) -> Callable[[environment.DeleteEnvironmentRequest], Awaitable[empty.Empty]]:
+ r"""Return a callable for the delete environment method over gRPC.
+
+ Deletes the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.DeleteEnvironmentRequest],
+ Awaitable[~.Empty]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_environment" not in self._stubs:
+ self._stubs["delete_environment"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/DeleteEnvironment",
+ request_serializer=environment.DeleteEnvironmentRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_environment"]
+
+ @property
+ def lookup_environment_history(
+ self,
+ ) -> Callable[
+ [environment.LookupEnvironmentHistoryRequest],
+ Awaitable[environment.LookupEnvironmentHistoryResponse],
+ ]:
+ r"""Return a callable for the lookup environment history method over gRPC.
+
+ Looks up the history of the specified
+ [Environment][google.cloud.dialogflow.cx.v3.Environment].
+
+ Returns:
+ Callable[[~.LookupEnvironmentHistoryRequest],
+ Awaitable[~.LookupEnvironmentHistoryResponse]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "lookup_environment_history" not in self._stubs:
+ self._stubs["lookup_environment_history"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Environments/LookupEnvironmentHistory",
+ request_serializer=environment.LookupEnvironmentHistoryRequest.serialize,
+ response_deserializer=environment.LookupEnvironmentHistoryResponse.deserialize,
+ )
+ return self._stubs["lookup_environment_history"]
+
+
+__all__ = ("EnvironmentsGrpcAsyncIOTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3beta1/types/ivr.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/__init__.py
similarity index 81%
rename from packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3beta1/types/ivr.py
rename to packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/__init__.py
index 32c9622b3e72..edf527738f65 100644
--- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3beta1/types/ivr.py
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/__init__.py
@@ -15,8 +15,10 @@
# limitations under the License.
#
+from .client import FlowsClient
+from .async_client import FlowsAsyncClient
-__protobuf__ = proto.module(package="google.cloud.dialogflow.cx.v3beta1", manifest={},)
-
-
-__all__ = tuple(sorted(__protobuf__.manifest))
+__all__ = (
+ "FlowsClient",
+ "FlowsAsyncClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/async_client.py
new file mode 100644
index 000000000000..31bfe6e60944
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/async_client.py
@@ -0,0 +1,697 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.dialogflowcx_v3.services.flows import pagers
+from google.cloud.dialogflowcx_v3.types import flow
+from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow
+from google.cloud.dialogflowcx_v3.types import page
+from google.protobuf import empty_pb2 as empty # type: ignore
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import struct_pb2 as struct # type: ignore
+
+from .transports.base import FlowsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import FlowsGrpcAsyncIOTransport
+from .client import FlowsClient
+
+
+class FlowsAsyncClient:
+ """Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow]."""
+
+ _client: FlowsClient
+
+ DEFAULT_ENDPOINT = FlowsClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = FlowsClient.DEFAULT_MTLS_ENDPOINT
+
+ flow_path = staticmethod(FlowsClient.flow_path)
+ parse_flow_path = staticmethod(FlowsClient.parse_flow_path)
+ intent_path = staticmethod(FlowsClient.intent_path)
+ parse_intent_path = staticmethod(FlowsClient.parse_intent_path)
+ page_path = staticmethod(FlowsClient.page_path)
+ parse_page_path = staticmethod(FlowsClient.parse_page_path)
+ webhook_path = staticmethod(FlowsClient.webhook_path)
+ parse_webhook_path = staticmethod(FlowsClient.parse_webhook_path)
+
+ common_billing_account_path = staticmethod(FlowsClient.common_billing_account_path)
+ parse_common_billing_account_path = staticmethod(
+ FlowsClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(FlowsClient.common_folder_path)
+ parse_common_folder_path = staticmethod(FlowsClient.parse_common_folder_path)
+
+ common_organization_path = staticmethod(FlowsClient.common_organization_path)
+ parse_common_organization_path = staticmethod(
+ FlowsClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(FlowsClient.common_project_path)
+ parse_common_project_path = staticmethod(FlowsClient.parse_common_project_path)
+
+ common_location_path = staticmethod(FlowsClient.common_location_path)
+ parse_common_location_path = staticmethod(FlowsClient.parse_common_location_path)
+
+ from_service_account_file = FlowsClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> FlowsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ FlowsTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(FlowsClient).get_transport_class, type(FlowsClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, FlowsTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the flows client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.FlowsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = FlowsClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def create_flow(
+ self,
+ request: gcdc_flow.CreateFlowRequest = None,
+ *,
+ parent: str = None,
+ flow: gcdc_flow.Flow = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_flow.Flow:
+ r"""Creates a flow in the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_flow.CreateFlowRequest`):
+ The request object. The request message for
+ [Flows.CreateFlow][google.cloud.dialogflow.cx.v3.Flows.CreateFlow].
+ parent (:class:`str`):
+ Required. The agent to create a flow for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ flow (:class:`~.gcdc_flow.Flow`):
+ Required. The flow to create.
+ This corresponds to the ``flow`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_flow.Flow:
+ Flows represents the conversation
+ flows when you build your chatbot agent.
+ A flow consists of many pages connected
+ by the transition routes. Conversations
+ always start with the built-in Start
+ Flow (with an all-0 ID). Transition
+ routes can direct the conversation
+ session from the current flow (parent
+ flow) to another flow (sub flow). When
+ the sub flow is finished, Dialogflow
+ will bring the session back to the
+ parent flow, where the sub flow is
+ started.
+
+ Usually, when a transition route is
+ followed by a matched intent, the intent
+ will be "consumed". This means the
+ intent won't activate more transition
+ routes. However, when the followed
+ transition route moves the conversation
+ session into a different flow, the
+ matched intent can be carried over and
+ to be consumed in the target flow.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_flow.CreateFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if flow is not None:
+ request.flow = flow
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_flow,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def delete_flow(
+ self,
+ request: flow.DeleteFlowRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes a specified flow.
+
+ Args:
+ request (:class:`~.flow.DeleteFlowRequest`):
+ The request object. The request message for
+ [Flows.DeleteFlow][google.cloud.dialogflow.cx.v3.Flows.DeleteFlow].
+ name (:class:`str`):
+ Required. The name of the flow to delete. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = flow.DeleteFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.delete_flow,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ async def list_flows(
+ self,
+ request: flow.ListFlowsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListFlowsAsyncPager:
+ r"""Returns the list of all flows in the specified agent.
+
+ Args:
+ request (:class:`~.flow.ListFlowsRequest`):
+ The request object. The request message for
+ [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows].
+ parent (:class:`str`):
+ Required. The agent containing the flows. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListFlowsAsyncPager:
+ The response message for
+ [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = flow.ListFlowsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_flows,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListFlowsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_flow(
+ self,
+ request: flow.GetFlowRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> flow.Flow:
+ r"""Retrieves the specified flow.
+
+ Args:
+ request (:class:`~.flow.GetFlowRequest`):
+ The request object. The response message for
+ [Flows.GetFlow][google.cloud.dialogflow.cx.v3.Flows.GetFlow].
+ name (:class:`str`):
+ Required. The name of the flow to get. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.flow.Flow:
+ Flows represents the conversation
+ flows when you build your chatbot agent.
+ A flow consists of many pages connected
+ by the transition routes. Conversations
+ always start with the built-in Start
+ Flow (with an all-0 ID). Transition
+ routes can direct the conversation
+ session from the current flow (parent
+ flow) to another flow (sub flow). When
+ the sub flow is finished, Dialogflow
+ will bring the session back to the
+ parent flow, where the sub flow is
+ started.
+
+ Usually, when a transition route is
+ followed by a matched intent, the intent
+ will be "consumed". This means the
+ intent won't activate more transition
+ routes. However, when the followed
+ transition route moves the conversation
+ session into a different flow, the
+ matched intent can be carried over and
+ to be consumed in the target flow.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = flow.GetFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_flow,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def update_flow(
+ self,
+ request: gcdc_flow.UpdateFlowRequest = None,
+ *,
+ flow: gcdc_flow.Flow = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_flow.Flow:
+ r"""Updates the specified flow.
+
+ Args:
+ request (:class:`~.gcdc_flow.UpdateFlowRequest`):
+ The request object. The request message for
+ [Flows.UpdateFlow][google.cloud.dialogflow.cx.v3.Flows.UpdateFlow].
+ flow (:class:`~.gcdc_flow.Flow`):
+ Required. The flow to update.
+ This corresponds to the ``flow`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ Required. The mask to control which fields get updated.
+ If ``update_mask`` is not specified, an error will be
+ returned.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_flow.Flow:
+ Flows represents the conversation
+ flows when you build your chatbot agent.
+ A flow consists of many pages connected
+ by the transition routes. Conversations
+ always start with the built-in Start
+ Flow (with an all-0 ID). Transition
+ routes can direct the conversation
+ session from the current flow (parent
+ flow) to another flow (sub flow). When
+ the sub flow is finished, Dialogflow
+ will bring the session back to the
+ parent flow, where the sub flow is
+ started.
+
+ Usually, when a transition route is
+ followed by a matched intent, the intent
+ will be "consumed". This means the
+ intent won't activate more transition
+ routes. However, when the followed
+ transition route moves the conversation
+ session into a different flow, the
+ matched intent can be carried over and
+ to be consumed in the target flow.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_flow.UpdateFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if flow is not None:
+ request.flow = flow
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_flow,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("flow.name", request.flow.name),)
+ ),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def train_flow(
+ self,
+ request: flow.TrainFlowRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Trains the specified flow. Note that only the flow in
+ 'draft' environment is trained.
+
+ Args:
+ request (:class:`~.flow.TrainFlowRequest`):
+ The request object. The request message for
+ [Flows.TrainFlow][google.cloud.dialogflow.cx.v3.Flows.TrainFlow].
+ name (:class:`str`):
+ Required. The flow to train. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.empty.Empty``: A generic empty message that
+ you can re-use to avoid defining duplicated empty
+ messages in your APIs. A typical example is to use it as
+ the request or the response type of an API method. For
+ instance:
+
+ ::
+
+ service Foo {
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ }
+
+ The JSON representation for ``Empty`` is empty JSON
+ object ``{}``.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = flow.TrainFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.train_flow,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ empty.Empty,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("FlowsAsyncClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/client.py
new file mode 100644
index 000000000000..b2c5b800d53c
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/client.py
@@ -0,0 +1,946 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from distutils import util
+import os
+import re
+from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
+import pkg_resources
+
+from google.api_core import client_options as client_options_lib # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport import mtls # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+from google.auth.exceptions import MutualTLSChannelError # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.dialogflowcx_v3.services.flows import pagers
+from google.cloud.dialogflowcx_v3.types import flow
+from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow
+from google.cloud.dialogflowcx_v3.types import page
+from google.protobuf import empty_pb2 as empty # type: ignore
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import struct_pb2 as struct # type: ignore
+
+from .transports.base import FlowsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc import FlowsGrpcTransport
+from .transports.grpc_asyncio import FlowsGrpcAsyncIOTransport
+
+
+class FlowsClientMeta(type):
+ """Metaclass for the Flows client.
+
+ This provides class-level methods for building and retrieving
+ support objects (e.g. transport) without polluting the client instance
+ objects.
+ """
+
+ _transport_registry = OrderedDict() # type: Dict[str, Type[FlowsTransport]]
+ _transport_registry["grpc"] = FlowsGrpcTransport
+ _transport_registry["grpc_asyncio"] = FlowsGrpcAsyncIOTransport
+
+ def get_transport_class(cls, label: str = None,) -> Type[FlowsTransport]:
+ """Return an appropriate transport class.
+
+ Args:
+ label: The name of the desired transport. If none is
+ provided, then the first transport in the registry is used.
+
+ Returns:
+ The transport class to use.
+ """
+ # If a specific transport is requested, return that one.
+ if label:
+ return cls._transport_registry[label]
+
+ # No transport is requested; return the default (that is, the first one
+ # in the dictionary).
+ return next(iter(cls._transport_registry.values()))
+
+
+class FlowsClient(metaclass=FlowsClientMeta):
+ """Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow]."""
+
+ @staticmethod
+ def _get_default_mtls_endpoint(api_endpoint):
+ """Convert api endpoint to mTLS endpoint.
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
+ Args:
+ api_endpoint (Optional[str]): the api endpoint to convert.
+ Returns:
+ str: converted mTLS api endpoint.
+ """
+ if not api_endpoint:
+ return api_endpoint
+
+ mtls_endpoint_re = re.compile(
+ r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?"
+ )
+
+ m = mtls_endpoint_re.match(api_endpoint)
+ name, mtls, sandbox, googledomain = m.groups()
+ if mtls or not googledomain:
+ return api_endpoint
+
+ if sandbox:
+ return api_endpoint.replace(
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
+ )
+
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
+
+ DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
+ DEFAULT_ENDPOINT
+ )
+
+ @classmethod
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ file.
+
+ Args:
+ filename (str): The path to the service account private key json
+ file.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ {@api.name}: The constructed client.
+ """
+ credentials = service_account.Credentials.from_service_account_file(filename)
+ kwargs["credentials"] = credentials
+ return cls(*args, **kwargs)
+
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> FlowsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ FlowsTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def flow_path(project: str, location: str, agent: str, flow: str,) -> str:
+ """Return a fully-qualified flow string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}".format(
+ project=project, location=location, agent=agent, flow=flow,
+ )
+
+ @staticmethod
+ def parse_flow_path(path: str) -> Dict[str, str]:
+ """Parse a flow path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def intent_path(project: str, location: str, agent: str, intent: str,) -> str:
+ """Return a fully-qualified intent string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(
+ project=project, location=location, agent=agent, intent=intent,
+ )
+
+ @staticmethod
+ def parse_intent_path(path: str) -> Dict[str, str]:
+ """Parse a intent path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def page_path(
+ project: str, location: str, agent: str, flow: str, page: str,
+ ) -> str:
+ """Return a fully-qualified page string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}".format(
+ project=project, location=location, agent=agent, flow=flow, page=page,
+ )
+
+ @staticmethod
+ def parse_page_path(path: str) -> Dict[str, str]:
+ """Parse a page path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/flows/(?P.+?)/pages/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def webhook_path(project: str, location: str, agent: str, webhook: str,) -> str:
+ """Return a fully-qualified webhook string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format(
+ project=project, location=location, agent=agent, webhook=webhook,
+ )
+
+ @staticmethod
+ def parse_webhook_path(path: str) -> Dict[str, str]:
+ """Parse a webhook path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/webhooks/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[credentials.Credentials] = None,
+ transport: Union[str, FlowsTransport, None] = None,
+ client_options: Optional[client_options_lib.ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the flows client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.FlowsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (client_options_lib.ClientOptions): Custom options for the
+ client. It won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+ if isinstance(client_options, dict):
+ client_options = client_options_lib.from_dict(client_options)
+ if client_options is None:
+ client_options = client_options_lib.ClientOptions()
+
+ # Create SSL credentials for mutual TLS if needed.
+ use_client_cert = bool(
+ util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
+ )
+
+ ssl_credentials = None
+ is_mtls = False
+ if use_client_cert:
+ if client_options.client_cert_source:
+ import grpc # type: ignore
+
+ cert, key = client_options.client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ is_mtls = True
+ else:
+ creds = SslCredentials()
+ is_mtls = creds.is_mtls
+ ssl_credentials = creds.ssl_credentials if is_mtls else 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":
+ api_endpoint = (
+ self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
+ )
+ else:
+ raise MutualTLSChannelError(
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ )
+
+ # 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:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its credentials directly."
+ )
+ if client_options.scopes:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its scopes directly."
+ )
+ self._transport = transport
+ else:
+ Transport = type(self).get_transport_class(transport)
+ self._transport = Transport(
+ credentials=credentials,
+ credentials_file=client_options.credentials_file,
+ host=api_endpoint,
+ scopes=client_options.scopes,
+ ssl_channel_credentials=ssl_credentials,
+ quota_project_id=client_options.quota_project_id,
+ client_info=client_info,
+ )
+
+ def create_flow(
+ self,
+ request: gcdc_flow.CreateFlowRequest = None,
+ *,
+ parent: str = None,
+ flow: gcdc_flow.Flow = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_flow.Flow:
+ r"""Creates a flow in the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_flow.CreateFlowRequest`):
+ The request object. The request message for
+ [Flows.CreateFlow][google.cloud.dialogflow.cx.v3.Flows.CreateFlow].
+ parent (:class:`str`):
+ Required. The agent to create a flow for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ flow (:class:`~.gcdc_flow.Flow`):
+ Required. The flow to create.
+ This corresponds to the ``flow`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_flow.Flow:
+ Flows represents the conversation
+ flows when you build your chatbot agent.
+ A flow consists of many pages connected
+ by the transition routes. Conversations
+ always start with the built-in Start
+ Flow (with an all-0 ID). Transition
+ routes can direct the conversation
+ session from the current flow (parent
+ flow) to another flow (sub flow). When
+ the sub flow is finished, Dialogflow
+ will bring the session back to the
+ parent flow, where the sub flow is
+ started.
+
+ Usually, when a transition route is
+ followed by a matched intent, the intent
+ will be "consumed". This means the
+ intent won't activate more transition
+ routes. However, when the followed
+ transition route moves the conversation
+ session into a different flow, the
+ matched intent can be carried over and
+ to be consumed in the target flow.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_flow.CreateFlowRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_flow.CreateFlowRequest):
+ request = gcdc_flow.CreateFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if flow is not None:
+ request.flow = flow
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_flow]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def delete_flow(
+ self,
+ request: flow.DeleteFlowRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes a specified flow.
+
+ Args:
+ request (:class:`~.flow.DeleteFlowRequest`):
+ The request object. The request message for
+ [Flows.DeleteFlow][google.cloud.dialogflow.cx.v3.Flows.DeleteFlow].
+ name (:class:`str`):
+ Required. The name of the flow to delete. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a flow.DeleteFlowRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, flow.DeleteFlowRequest):
+ request = flow.DeleteFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.delete_flow]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ def list_flows(
+ self,
+ request: flow.ListFlowsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListFlowsPager:
+ r"""Returns the list of all flows in the specified agent.
+
+ Args:
+ request (:class:`~.flow.ListFlowsRequest`):
+ The request object. The request message for
+ [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows].
+ parent (:class:`str`):
+ Required. The agent containing the flows. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListFlowsPager:
+ The response message for
+ [Flows.ListFlows][google.cloud.dialogflow.cx.v3.Flows.ListFlows].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a flow.ListFlowsRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, flow.ListFlowsRequest):
+ request = flow.ListFlowsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.list_flows]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.ListFlowsPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_flow(
+ self,
+ request: flow.GetFlowRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> flow.Flow:
+ r"""Retrieves the specified flow.
+
+ Args:
+ request (:class:`~.flow.GetFlowRequest`):
+ The request object. The response message for
+ [Flows.GetFlow][google.cloud.dialogflow.cx.v3.Flows.GetFlow].
+ name (:class:`str`):
+ Required. The name of the flow to get. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.flow.Flow:
+ Flows represents the conversation
+ flows when you build your chatbot agent.
+ A flow consists of many pages connected
+ by the transition routes. Conversations
+ always start with the built-in Start
+ Flow (with an all-0 ID). Transition
+ routes can direct the conversation
+ session from the current flow (parent
+ flow) to another flow (sub flow). When
+ the sub flow is finished, Dialogflow
+ will bring the session back to the
+ parent flow, where the sub flow is
+ started.
+
+ Usually, when a transition route is
+ followed by a matched intent, the intent
+ will be "consumed". This means the
+ intent won't activate more transition
+ routes. However, when the followed
+ transition route moves the conversation
+ session into a different flow, the
+ matched intent can be carried over and
+ to be consumed in the target flow.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a flow.GetFlowRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, flow.GetFlowRequest):
+ request = flow.GetFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_flow]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def update_flow(
+ self,
+ request: gcdc_flow.UpdateFlowRequest = None,
+ *,
+ flow: gcdc_flow.Flow = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_flow.Flow:
+ r"""Updates the specified flow.
+
+ Args:
+ request (:class:`~.gcdc_flow.UpdateFlowRequest`):
+ The request object. The request message for
+ [Flows.UpdateFlow][google.cloud.dialogflow.cx.v3.Flows.UpdateFlow].
+ flow (:class:`~.gcdc_flow.Flow`):
+ Required. The flow to update.
+ This corresponds to the ``flow`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ Required. The mask to control which fields get updated.
+ If ``update_mask`` is not specified, an error will be
+ returned.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_flow.Flow:
+ Flows represents the conversation
+ flows when you build your chatbot agent.
+ A flow consists of many pages connected
+ by the transition routes. Conversations
+ always start with the built-in Start
+ Flow (with an all-0 ID). Transition
+ routes can direct the conversation
+ session from the current flow (parent
+ flow) to another flow (sub flow). When
+ the sub flow is finished, Dialogflow
+ will bring the session back to the
+ parent flow, where the sub flow is
+ started.
+
+ Usually, when a transition route is
+ followed by a matched intent, the intent
+ will be "consumed". This means the
+ intent won't activate more transition
+ routes. However, when the followed
+ transition route moves the conversation
+ session into a different flow, the
+ matched intent can be carried over and
+ to be consumed in the target flow.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_flow.UpdateFlowRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_flow.UpdateFlowRequest):
+ request = gcdc_flow.UpdateFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if flow is not None:
+ request.flow = flow
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_flow]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("flow.name", request.flow.name),)
+ ),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def train_flow(
+ self,
+ request: flow.TrainFlowRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Trains the specified flow. Note that only the flow in
+ 'draft' environment is trained.
+
+ Args:
+ request (:class:`~.flow.TrainFlowRequest`):
+ The request object. The request message for
+ [Flows.TrainFlow][google.cloud.dialogflow.cx.v3.Flows.TrainFlow].
+ name (:class:`str`):
+ Required. The flow to train. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.empty.Empty``: A generic empty message that
+ you can re-use to avoid defining duplicated empty
+ messages in your APIs. A typical example is to use it as
+ the request or the response type of an API method. For
+ instance:
+
+ ::
+
+ service Foo {
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ }
+
+ The JSON representation for ``Empty`` is empty JSON
+ object ``{}``.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a flow.TrainFlowRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, flow.TrainFlowRequest):
+ request = flow.TrainFlowRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.train_flow]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ empty.Empty,
+ metadata_type=struct.Struct,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("FlowsClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/pagers.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/pagers.py
new file mode 100644
index 000000000000..bf55d3bbfa53
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/pagers.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
+
+from google.cloud.dialogflowcx_v3.types import flow
+
+
+class ListFlowsPager:
+ """A pager for iterating through ``list_flows`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.flow.ListFlowsResponse` object, and
+ provides an ``__iter__`` method to iterate through its
+ ``flows`` field.
+
+ If there are more pages, the ``__iter__`` method will make additional
+ ``ListFlows`` requests and continue to iterate
+ through the ``flows`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.flow.ListFlowsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., flow.ListFlowsResponse],
+ request: flow.ListFlowsRequest,
+ response: flow.ListFlowsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.flow.ListFlowsRequest`):
+ The initial request object.
+ response (:class:`~.flow.ListFlowsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = flow.ListFlowsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ def pages(self) -> Iterable[flow.ListFlowsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __iter__(self) -> Iterable[flow.Flow]:
+ for page in self.pages:
+ yield from page.flows
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class ListFlowsAsyncPager:
+ """A pager for iterating through ``list_flows`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.flow.ListFlowsResponse` object, and
+ provides an ``__aiter__`` method to iterate through its
+ ``flows`` field.
+
+ If there are more pages, the ``__aiter__`` method will make additional
+ ``ListFlows`` requests and continue to iterate
+ through the ``flows`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.flow.ListFlowsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., Awaitable[flow.ListFlowsResponse]],
+ request: flow.ListFlowsRequest,
+ response: flow.ListFlowsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.flow.ListFlowsRequest`):
+ The initial request object.
+ response (:class:`~.flow.ListFlowsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = flow.ListFlowsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ async def pages(self) -> AsyncIterable[flow.ListFlowsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = await self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __aiter__(self) -> AsyncIterable[flow.Flow]:
+ async def async_generator():
+ async for page in self.pages:
+ for response in page.flows:
+ yield response
+
+ return async_generator()
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py
new file mode 100644
index 000000000000..d43aadd76cda
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/__init__.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from typing import Dict, Type
+
+from .base import FlowsTransport
+from .grpc import FlowsGrpcTransport
+from .grpc_asyncio import FlowsGrpcAsyncIOTransport
+
+
+# Compile a registry of transports.
+_transport_registry = OrderedDict() # type: Dict[str, Type[FlowsTransport]]
+_transport_registry["grpc"] = FlowsGrpcTransport
+_transport_registry["grpc_asyncio"] = FlowsGrpcAsyncIOTransport
+
+
+__all__ = (
+ "FlowsTransport",
+ "FlowsGrpcTransport",
+ "FlowsGrpcAsyncIOTransport",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/base.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/base.py
new file mode 100644
index 000000000000..750a522e6e5b
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/base.py
@@ -0,0 +1,195 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 abc
+import typing
+import pkg_resources
+
+from google import auth # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google.auth import credentials # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import flow
+from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+class FlowsTransport(abc.ABC):
+ """Abstract transport class for Flows."""
+
+ AUTH_SCOPES = (
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/dialogflow",
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: typing.Optional[str] = None,
+ scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
+ quota_project_id: typing.Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ **kwargs,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scope (Optional[Sequence[str]]): A list of scopes.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+ """
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
+ if ":" not in host:
+ host += ":443"
+ self._host = host
+
+ # If no credentials are provided, then determine the appropriate
+ # defaults.
+ if credentials and credentials_file:
+ raise exceptions.DuplicateCredentialArgs(
+ "'credentials_file' and 'credentials' are mutually exclusive"
+ )
+
+ if credentials_file is not None:
+ credentials, _ = auth.load_credentials_from_file(
+ credentials_file, scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ elif credentials is None:
+ credentials, _ = auth.default(
+ scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ # Save the credentials.
+ self._credentials = credentials
+
+ # Lifted into its own function so it can be stubbed out during tests.
+ self._prep_wrapped_messages(client_info)
+
+ def _prep_wrapped_messages(self, client_info):
+ # Precompute the wrapped methods.
+ self._wrapped_methods = {
+ self.create_flow: gapic_v1.method.wrap_method(
+ self.create_flow, default_timeout=None, client_info=client_info,
+ ),
+ self.delete_flow: gapic_v1.method.wrap_method(
+ self.delete_flow, default_timeout=None, client_info=client_info,
+ ),
+ self.list_flows: gapic_v1.method.wrap_method(
+ self.list_flows, default_timeout=None, client_info=client_info,
+ ),
+ self.get_flow: gapic_v1.method.wrap_method(
+ self.get_flow, default_timeout=None, client_info=client_info,
+ ),
+ self.update_flow: gapic_v1.method.wrap_method(
+ self.update_flow, default_timeout=None, client_info=client_info,
+ ),
+ self.train_flow: gapic_v1.method.wrap_method(
+ self.train_flow, default_timeout=None, client_info=client_info,
+ ),
+ }
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsClient:
+ """Return the client designed to process long-running operations."""
+ raise NotImplementedError()
+
+ @property
+ def create_flow(
+ self,
+ ) -> typing.Callable[
+ [gcdc_flow.CreateFlowRequest],
+ typing.Union[gcdc_flow.Flow, typing.Awaitable[gcdc_flow.Flow]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def delete_flow(
+ self,
+ ) -> typing.Callable[
+ [flow.DeleteFlowRequest],
+ typing.Union[empty.Empty, typing.Awaitable[empty.Empty]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def list_flows(
+ self,
+ ) -> typing.Callable[
+ [flow.ListFlowsRequest],
+ typing.Union[flow.ListFlowsResponse, typing.Awaitable[flow.ListFlowsResponse]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def get_flow(
+ self,
+ ) -> typing.Callable[
+ [flow.GetFlowRequest], typing.Union[flow.Flow, typing.Awaitable[flow.Flow]]
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def update_flow(
+ self,
+ ) -> typing.Callable[
+ [gcdc_flow.UpdateFlowRequest],
+ typing.Union[gcdc_flow.Flow, typing.Awaitable[gcdc_flow.Flow]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def train_flow(
+ self,
+ ) -> typing.Callable[
+ [flow.TrainFlowRequest],
+ typing.Union[operations.Operation, typing.Awaitable[operations.Operation]],
+ ]:
+ raise NotImplementedError()
+
+
+__all__ = ("FlowsTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py
new file mode 100644
index 000000000000..6efec1ad75d5
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/grpc.py
@@ -0,0 +1,398 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import grpc_helpers # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import flow
+from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import FlowsTransport, DEFAULT_CLIENT_INFO
+
+
+class FlowsGrpcTransport(FlowsTransport):
+ """gRPC backend transport for Flows.
+
+ Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _stubs: Dict[str, Callable]
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Sequence[str] = None,
+ channel: grpc.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id: Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
+ ignored if ``channel`` is provided.
+ channel (Optional[grpc.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ self._stubs = {} # type: Dict[str, Callable]
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> grpc.Channel:
+ """Create and return a gRPC channel object.
+ Args:
+ address (Optionsl[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ grpc.Channel: A gRPC channel object.
+
+ Raises:
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ @property
+ def grpc_channel(self) -> grpc.Channel:
+ """Return the channel designed to connect to this service.
+ """
+ return self._grpc_channel
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsClient:
+ """Create the client designed to process long-running operations.
+
+ 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.
+ if "operations_client" not in self.__dict__:
+ self.__dict__["operations_client"] = operations_v1.OperationsClient(
+ self.grpc_channel
+ )
+
+ # Return the client from cache.
+ return self.__dict__["operations_client"]
+
+ @property
+ def create_flow(self) -> Callable[[gcdc_flow.CreateFlowRequest], gcdc_flow.Flow]:
+ r"""Return a callable for the create flow method over gRPC.
+
+ Creates a flow in the specified agent.
+
+ Returns:
+ Callable[[~.CreateFlowRequest],
+ ~.Flow]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_flow" not in self._stubs:
+ self._stubs["create_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/CreateFlow",
+ request_serializer=gcdc_flow.CreateFlowRequest.serialize,
+ response_deserializer=gcdc_flow.Flow.deserialize,
+ )
+ return self._stubs["create_flow"]
+
+ @property
+ def delete_flow(self) -> Callable[[flow.DeleteFlowRequest], empty.Empty]:
+ r"""Return a callable for the delete flow method over gRPC.
+
+ Deletes a specified flow.
+
+ Returns:
+ Callable[[~.DeleteFlowRequest],
+ ~.Empty]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_flow" not in self._stubs:
+ self._stubs["delete_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/DeleteFlow",
+ request_serializer=flow.DeleteFlowRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_flow"]
+
+ @property
+ def list_flows(self) -> Callable[[flow.ListFlowsRequest], flow.ListFlowsResponse]:
+ r"""Return a callable for the list flows method over gRPC.
+
+ Returns the list of all flows in the specified agent.
+
+ Returns:
+ Callable[[~.ListFlowsRequest],
+ ~.ListFlowsResponse]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_flows" not in self._stubs:
+ self._stubs["list_flows"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/ListFlows",
+ request_serializer=flow.ListFlowsRequest.serialize,
+ response_deserializer=flow.ListFlowsResponse.deserialize,
+ )
+ return self._stubs["list_flows"]
+
+ @property
+ def get_flow(self) -> Callable[[flow.GetFlowRequest], flow.Flow]:
+ r"""Return a callable for the get flow method over gRPC.
+
+ Retrieves the specified flow.
+
+ Returns:
+ Callable[[~.GetFlowRequest],
+ ~.Flow]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_flow" not in self._stubs:
+ self._stubs["get_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/GetFlow",
+ request_serializer=flow.GetFlowRequest.serialize,
+ response_deserializer=flow.Flow.deserialize,
+ )
+ return self._stubs["get_flow"]
+
+ @property
+ def update_flow(self) -> Callable[[gcdc_flow.UpdateFlowRequest], gcdc_flow.Flow]:
+ r"""Return a callable for the update flow method over gRPC.
+
+ Updates the specified flow.
+
+ Returns:
+ Callable[[~.UpdateFlowRequest],
+ ~.Flow]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_flow" not in self._stubs:
+ self._stubs["update_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/UpdateFlow",
+ request_serializer=gcdc_flow.UpdateFlowRequest.serialize,
+ response_deserializer=gcdc_flow.Flow.deserialize,
+ )
+ return self._stubs["update_flow"]
+
+ @property
+ def train_flow(self) -> Callable[[flow.TrainFlowRequest], operations.Operation]:
+ r"""Return a callable for the train flow method over gRPC.
+
+ Trains the specified flow. Note that only the flow in
+ 'draft' environment is trained.
+
+ Returns:
+ Callable[[~.TrainFlowRequest],
+ ~.Operation]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "train_flow" not in self._stubs:
+ self._stubs["train_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/TrainFlow",
+ request_serializer=flow.TrainFlowRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["train_flow"]
+
+
+__all__ = ("FlowsGrpcTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py
new file mode 100644
index 000000000000..98ff7b166eb1
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/flows/transports/grpc_asyncio.py
@@ -0,0 +1,410 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import grpc_helpers_async # type: ignore
+from google.api_core import operations_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+from grpc.experimental import aio # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import flow
+from google.cloud.dialogflowcx_v3.types import flow as gcdc_flow
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import FlowsTransport, DEFAULT_CLIENT_INFO
+from .grpc import FlowsGrpcTransport
+
+
+class FlowsGrpcAsyncIOTransport(FlowsTransport):
+ """gRPC AsyncIO backend transport for Flows.
+
+ Service for managing [Flows][google.cloud.dialogflow.cx.v3.Flow].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _grpc_channel: aio.Channel
+ _stubs: Dict[str, Callable] = {}
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> aio.Channel:
+ """Create and return a gRPC AsyncIO channel object.
+ Args:
+ address (Optional[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ aio.Channel: A gRPC AsyncIO channel object.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers_async.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: aio.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id=None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ channel (Optional[aio.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ self._stubs = {}
+
+ @property
+ def grpc_channel(self) -> aio.Channel:
+ """Create the channel designed to connect to this service.
+
+ This property caches on the instance; repeated calls return
+ the same channel.
+ """
+ # Return the channel from cache.
+ return self._grpc_channel
+
+ @property
+ def operations_client(self) -> operations_v1.OperationsAsyncClient:
+ """Create the client designed to process long-running operations.
+
+ 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.
+ if "operations_client" not in self.__dict__:
+ self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient(
+ self.grpc_channel
+ )
+
+ # Return the client from cache.
+ return self.__dict__["operations_client"]
+
+ @property
+ def create_flow(
+ self,
+ ) -> Callable[[gcdc_flow.CreateFlowRequest], Awaitable[gcdc_flow.Flow]]:
+ r"""Return a callable for the create flow method over gRPC.
+
+ Creates a flow in the specified agent.
+
+ Returns:
+ Callable[[~.CreateFlowRequest],
+ Awaitable[~.Flow]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_flow" not in self._stubs:
+ self._stubs["create_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/CreateFlow",
+ request_serializer=gcdc_flow.CreateFlowRequest.serialize,
+ response_deserializer=gcdc_flow.Flow.deserialize,
+ )
+ return self._stubs["create_flow"]
+
+ @property
+ def delete_flow(self) -> Callable[[flow.DeleteFlowRequest], Awaitable[empty.Empty]]:
+ r"""Return a callable for the delete flow method over gRPC.
+
+ Deletes a specified flow.
+
+ Returns:
+ Callable[[~.DeleteFlowRequest],
+ Awaitable[~.Empty]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_flow" not in self._stubs:
+ self._stubs["delete_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/DeleteFlow",
+ request_serializer=flow.DeleteFlowRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_flow"]
+
+ @property
+ def list_flows(
+ self,
+ ) -> Callable[[flow.ListFlowsRequest], Awaitable[flow.ListFlowsResponse]]:
+ r"""Return a callable for the list flows method over gRPC.
+
+ Returns the list of all flows in the specified agent.
+
+ Returns:
+ Callable[[~.ListFlowsRequest],
+ Awaitable[~.ListFlowsResponse]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_flows" not in self._stubs:
+ self._stubs["list_flows"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/ListFlows",
+ request_serializer=flow.ListFlowsRequest.serialize,
+ response_deserializer=flow.ListFlowsResponse.deserialize,
+ )
+ return self._stubs["list_flows"]
+
+ @property
+ def get_flow(self) -> Callable[[flow.GetFlowRequest], Awaitable[flow.Flow]]:
+ r"""Return a callable for the get flow method over gRPC.
+
+ Retrieves the specified flow.
+
+ Returns:
+ Callable[[~.GetFlowRequest],
+ Awaitable[~.Flow]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_flow" not in self._stubs:
+ self._stubs["get_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/GetFlow",
+ request_serializer=flow.GetFlowRequest.serialize,
+ response_deserializer=flow.Flow.deserialize,
+ )
+ return self._stubs["get_flow"]
+
+ @property
+ def update_flow(
+ self,
+ ) -> Callable[[gcdc_flow.UpdateFlowRequest], Awaitable[gcdc_flow.Flow]]:
+ r"""Return a callable for the update flow method over gRPC.
+
+ Updates the specified flow.
+
+ Returns:
+ Callable[[~.UpdateFlowRequest],
+ Awaitable[~.Flow]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_flow" not in self._stubs:
+ self._stubs["update_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/UpdateFlow",
+ request_serializer=gcdc_flow.UpdateFlowRequest.serialize,
+ response_deserializer=gcdc_flow.Flow.deserialize,
+ )
+ return self._stubs["update_flow"]
+
+ @property
+ def train_flow(
+ self,
+ ) -> Callable[[flow.TrainFlowRequest], Awaitable[operations.Operation]]:
+ r"""Return a callable for the train flow method over gRPC.
+
+ Trains the specified flow. Note that only the flow in
+ 'draft' environment is trained.
+
+ Returns:
+ Callable[[~.TrainFlowRequest],
+ Awaitable[~.Operation]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "train_flow" not in self._stubs:
+ self._stubs["train_flow"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Flows/TrainFlow",
+ request_serializer=flow.TrainFlowRequest.serialize,
+ response_deserializer=operations.Operation.FromString,
+ )
+ return self._stubs["train_flow"]
+
+
+__all__ = ("FlowsGrpcAsyncIOTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/__init__.py
new file mode 100644
index 000000000000..8719a9b649d8
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from .client import IntentsClient
+from .async_client import IntentsAsyncClient
+
+__all__ = (
+ "IntentsClient",
+ "IntentsAsyncClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/async_client.py
new file mode 100644
index 000000000000..04ee85cf0621
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/async_client.py
@@ -0,0 +1,549 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.cloud.dialogflowcx_v3.services.intents import pagers
+from google.cloud.dialogflowcx_v3.types import intent
+from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+
+from .transports.base import IntentsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import IntentsGrpcAsyncIOTransport
+from .client import IntentsClient
+
+
+class IntentsAsyncClient:
+ """Service for managing
+ [Intents][google.cloud.dialogflow.cx.v3.Intent].
+ """
+
+ _client: IntentsClient
+
+ DEFAULT_ENDPOINT = IntentsClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = IntentsClient.DEFAULT_MTLS_ENDPOINT
+
+ entity_type_path = staticmethod(IntentsClient.entity_type_path)
+ parse_entity_type_path = staticmethod(IntentsClient.parse_entity_type_path)
+ intent_path = staticmethod(IntentsClient.intent_path)
+ parse_intent_path = staticmethod(IntentsClient.parse_intent_path)
+
+ common_billing_account_path = staticmethod(
+ IntentsClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ IntentsClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(IntentsClient.common_folder_path)
+ parse_common_folder_path = staticmethod(IntentsClient.parse_common_folder_path)
+
+ common_organization_path = staticmethod(IntentsClient.common_organization_path)
+ parse_common_organization_path = staticmethod(
+ IntentsClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(IntentsClient.common_project_path)
+ parse_common_project_path = staticmethod(IntentsClient.parse_common_project_path)
+
+ common_location_path = staticmethod(IntentsClient.common_location_path)
+ parse_common_location_path = staticmethod(IntentsClient.parse_common_location_path)
+
+ from_service_account_file = IntentsClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> IntentsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ IntentsTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(IntentsClient).get_transport_class, type(IntentsClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, IntentsTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the intents client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.IntentsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = IntentsClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def list_intents(
+ self,
+ request: intent.ListIntentsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListIntentsAsyncPager:
+ r"""Returns the list of all intents in the specified
+ agent.
+
+ Args:
+ request (:class:`~.intent.ListIntentsRequest`):
+ The request object. The request message for
+ [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents].
+ parent (:class:`str`):
+ Required. The agent to list all intents for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListIntentsAsyncPager:
+ The response message for
+ [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = intent.ListIntentsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_intents,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListIntentsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_intent(
+ self,
+ request: intent.GetIntentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> intent.Intent:
+ r"""Retrieves the specified intent.
+
+ Args:
+ request (:class:`~.intent.GetIntentRequest`):
+ The request object. The request message for
+ [Intents.GetIntent][google.cloud.dialogflow.cx.v3.Intents.GetIntent].
+ name (:class:`str`):
+ Required. The name of the intent. Format:
+ ``projects//locations//agents//intents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.intent.Intent:
+ An intent represents a user's intent
+ to interact with a conversational agent.
+ You can provide information for the
+ Dialogflow API to use to match user
+ input to an intent by adding training
+ phrases (i.e., examples of user input)
+ to your intent.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = intent.GetIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_intent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def create_intent(
+ self,
+ request: gcdc_intent.CreateIntentRequest = None,
+ *,
+ parent: str = None,
+ intent: gcdc_intent.Intent = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_intent.Intent:
+ r"""Creates an intent in the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_intent.CreateIntentRequest`):
+ The request object. The request message for
+ [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent].
+ parent (:class:`str`):
+ Required. The agent to create an intent for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ intent (:class:`~.gcdc_intent.Intent`):
+ Required. The intent to create.
+ This corresponds to the ``intent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_intent.Intent:
+ An intent represents a user's intent
+ to interact with a conversational agent.
+ You can provide information for the
+ Dialogflow API to use to match user
+ input to an intent by adding training
+ phrases (i.e., examples of user input)
+ to your intent.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_intent.CreateIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if intent is not None:
+ request.intent = intent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_intent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def update_intent(
+ self,
+ request: gcdc_intent.UpdateIntentRequest = None,
+ *,
+ intent: gcdc_intent.Intent = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_intent.Intent:
+ r"""Updates the specified intent.
+
+ Args:
+ request (:class:`~.gcdc_intent.UpdateIntentRequest`):
+ The request object. The request message for
+ [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent].
+ intent (:class:`~.gcdc_intent.Intent`):
+ Required. The intent to update.
+ This corresponds to the ``intent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ The mask to control which fields get
+ updated. If the mask is not present, all
+ fields will be updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_intent.Intent:
+ An intent represents a user's intent
+ to interact with a conversational agent.
+ You can provide information for the
+ Dialogflow API to use to match user
+ input to an intent by adding training
+ phrases (i.e., examples of user input)
+ to your intent.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gcdc_intent.UpdateIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if intent is not None:
+ request.intent = intent
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_intent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("intent.name", request.intent.name),)
+ ),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def delete_intent(
+ self,
+ request: intent.DeleteIntentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified intent.
+
+ Args:
+ request (:class:`~.intent.DeleteIntentRequest`):
+ The request object. The request message for
+ [Intents.DeleteIntent][google.cloud.dialogflow.cx.v3.Intents.DeleteIntent].
+ name (:class:`str`):
+ Required. The name of the intent to delete. Format:
+ ``projects//locations//agents//intents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = intent.DeleteIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.delete_intent,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("IntentsAsyncClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/client.py
new file mode 100644
index 000000000000..63d5ef524d73
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/client.py
@@ -0,0 +1,767 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from distutils import util
+import os
+import re
+from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
+import pkg_resources
+
+from google.api_core import client_options as client_options_lib # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport import mtls # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+from google.auth.exceptions import MutualTLSChannelError # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.cloud.dialogflowcx_v3.services.intents import pagers
+from google.cloud.dialogflowcx_v3.types import intent
+from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+
+from .transports.base import IntentsTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc import IntentsGrpcTransport
+from .transports.grpc_asyncio import IntentsGrpcAsyncIOTransport
+
+
+class IntentsClientMeta(type):
+ """Metaclass for the Intents client.
+
+ This provides class-level methods for building and retrieving
+ support objects (e.g. transport) without polluting the client instance
+ objects.
+ """
+
+ _transport_registry = OrderedDict() # type: Dict[str, Type[IntentsTransport]]
+ _transport_registry["grpc"] = IntentsGrpcTransport
+ _transport_registry["grpc_asyncio"] = IntentsGrpcAsyncIOTransport
+
+ def get_transport_class(cls, label: str = None,) -> Type[IntentsTransport]:
+ """Return an appropriate transport class.
+
+ Args:
+ label: The name of the desired transport. If none is
+ provided, then the first transport in the registry is used.
+
+ Returns:
+ The transport class to use.
+ """
+ # If a specific transport is requested, return that one.
+ if label:
+ return cls._transport_registry[label]
+
+ # No transport is requested; return the default (that is, the first one
+ # in the dictionary).
+ return next(iter(cls._transport_registry.values()))
+
+
+class IntentsClient(metaclass=IntentsClientMeta):
+ """Service for managing
+ [Intents][google.cloud.dialogflow.cx.v3.Intent].
+ """
+
+ @staticmethod
+ def _get_default_mtls_endpoint(api_endpoint):
+ """Convert api endpoint to mTLS endpoint.
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
+ Args:
+ api_endpoint (Optional[str]): the api endpoint to convert.
+ Returns:
+ str: converted mTLS api endpoint.
+ """
+ if not api_endpoint:
+ return api_endpoint
+
+ mtls_endpoint_re = re.compile(
+ r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?"
+ )
+
+ m = mtls_endpoint_re.match(api_endpoint)
+ name, mtls, sandbox, googledomain = m.groups()
+ if mtls or not googledomain:
+ return api_endpoint
+
+ if sandbox:
+ return api_endpoint.replace(
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
+ )
+
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
+
+ DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
+ DEFAULT_ENDPOINT
+ )
+
+ @classmethod
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ file.
+
+ Args:
+ filename (str): The path to the service account private key json
+ file.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ {@api.name}: The constructed client.
+ """
+ credentials = service_account.Credentials.from_service_account_file(filename)
+ kwargs["credentials"] = credentials
+ return cls(*args, **kwargs)
+
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> IntentsTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ IntentsTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def entity_type_path(
+ project: str, location: str, agent: str, entity_type: str,
+ ) -> str:
+ """Return a fully-qualified entity_type string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}".format(
+ project=project, location=location, agent=agent, entity_type=entity_type,
+ )
+
+ @staticmethod
+ def parse_entity_type_path(path: str) -> Dict[str, str]:
+ """Parse a entity_type path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/entityTypes/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def intent_path(project: str, location: str, agent: str, intent: str,) -> str:
+ """Return a fully-qualified intent string."""
+ return "projects/{project}/locations/{location}/agents/{agent}/intents/{intent}".format(
+ project=project, location=location, agent=agent, intent=intent,
+ )
+
+ @staticmethod
+ def parse_intent_path(path: str) -> Dict[str, str]:
+ """Parse a intent path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/locations/(?P.+?)/agents/(?P.+?)/intents/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[credentials.Credentials] = None,
+ transport: Union[str, IntentsTransport, None] = None,
+ client_options: Optional[client_options_lib.ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the intents client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.IntentsTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (client_options_lib.ClientOptions): Custom options for the
+ client. It won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+ if isinstance(client_options, dict):
+ client_options = client_options_lib.from_dict(client_options)
+ if client_options is None:
+ client_options = client_options_lib.ClientOptions()
+
+ # Create SSL credentials for mutual TLS if needed.
+ use_client_cert = bool(
+ util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
+ )
+
+ ssl_credentials = None
+ is_mtls = False
+ if use_client_cert:
+ if client_options.client_cert_source:
+ import grpc # type: ignore
+
+ cert, key = client_options.client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ is_mtls = True
+ else:
+ creds = SslCredentials()
+ is_mtls = creds.is_mtls
+ ssl_credentials = creds.ssl_credentials if is_mtls else 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":
+ api_endpoint = (
+ self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
+ )
+ else:
+ raise MutualTLSChannelError(
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ )
+
+ # 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:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its credentials directly."
+ )
+ if client_options.scopes:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its scopes directly."
+ )
+ self._transport = transport
+ else:
+ Transport = type(self).get_transport_class(transport)
+ self._transport = Transport(
+ credentials=credentials,
+ credentials_file=client_options.credentials_file,
+ host=api_endpoint,
+ scopes=client_options.scopes,
+ ssl_channel_credentials=ssl_credentials,
+ quota_project_id=client_options.quota_project_id,
+ client_info=client_info,
+ )
+
+ def list_intents(
+ self,
+ request: intent.ListIntentsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListIntentsPager:
+ r"""Returns the list of all intents in the specified
+ agent.
+
+ Args:
+ request (:class:`~.intent.ListIntentsRequest`):
+ The request object. The request message for
+ [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents].
+ parent (:class:`str`):
+ Required. The agent to list all intents for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListIntentsPager:
+ The response message for
+ [Intents.ListIntents][google.cloud.dialogflow.cx.v3.Intents.ListIntents].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a intent.ListIntentsRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, intent.ListIntentsRequest):
+ request = intent.ListIntentsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.list_intents]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.ListIntentsPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_intent(
+ self,
+ request: intent.GetIntentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> intent.Intent:
+ r"""Retrieves the specified intent.
+
+ Args:
+ request (:class:`~.intent.GetIntentRequest`):
+ The request object. The request message for
+ [Intents.GetIntent][google.cloud.dialogflow.cx.v3.Intents.GetIntent].
+ name (:class:`str`):
+ Required. The name of the intent. Format:
+ ``projects//locations//agents//intents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.intent.Intent:
+ An intent represents a user's intent
+ to interact with a conversational agent.
+ You can provide information for the
+ Dialogflow API to use to match user
+ input to an intent by adding training
+ phrases (i.e., examples of user input)
+ to your intent.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a intent.GetIntentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, intent.GetIntentRequest):
+ request = intent.GetIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_intent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def create_intent(
+ self,
+ request: gcdc_intent.CreateIntentRequest = None,
+ *,
+ parent: str = None,
+ intent: gcdc_intent.Intent = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_intent.Intent:
+ r"""Creates an intent in the specified agent.
+
+ Args:
+ request (:class:`~.gcdc_intent.CreateIntentRequest`):
+ The request object. The request message for
+ [Intents.CreateIntent][google.cloud.dialogflow.cx.v3.Intents.CreateIntent].
+ parent (:class:`str`):
+ Required. The agent to create an intent for. Format:
+ ``projects//locations//agents/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ intent (:class:`~.gcdc_intent.Intent`):
+ Required. The intent to create.
+ This corresponds to the ``intent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_intent.Intent:
+ An intent represents a user's intent
+ to interact with a conversational agent.
+ You can provide information for the
+ Dialogflow API to use to match user
+ input to an intent by adding training
+ phrases (i.e., examples of user input)
+ to your intent.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_intent.CreateIntentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_intent.CreateIntentRequest):
+ request = gcdc_intent.CreateIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if intent is not None:
+ request.intent = intent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_intent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def update_intent(
+ self,
+ request: gcdc_intent.UpdateIntentRequest = None,
+ *,
+ intent: gcdc_intent.Intent = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gcdc_intent.Intent:
+ r"""Updates the specified intent.
+
+ Args:
+ request (:class:`~.gcdc_intent.UpdateIntentRequest`):
+ The request object. The request message for
+ [Intents.UpdateIntent][google.cloud.dialogflow.cx.v3.Intents.UpdateIntent].
+ intent (:class:`~.gcdc_intent.Intent`):
+ Required. The intent to update.
+ This corresponds to the ``intent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ The mask to control which fields get
+ updated. If the mask is not present, all
+ fields will be updated.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gcdc_intent.Intent:
+ An intent represents a user's intent
+ to interact with a conversational agent.
+ You can provide information for the
+ Dialogflow API to use to match user
+ input to an intent by adding training
+ phrases (i.e., examples of user input)
+ to your intent.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gcdc_intent.UpdateIntentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gcdc_intent.UpdateIntentRequest):
+ request = gcdc_intent.UpdateIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if intent is not None:
+ request.intent = intent
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_intent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("intent.name", request.intent.name),)
+ ),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def delete_intent(
+ self,
+ request: intent.DeleteIntentRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes the specified intent.
+
+ Args:
+ request (:class:`~.intent.DeleteIntentRequest`):
+ The request object. The request message for
+ [Intents.DeleteIntent][google.cloud.dialogflow.cx.v3.Intents.DeleteIntent].
+ name (:class:`str`):
+ Required. The name of the intent to delete. Format:
+ ``projects//locations//agents//intents/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ 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
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a intent.DeleteIntentRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, intent.DeleteIntentRequest):
+ request = intent.DeleteIntentRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.delete_intent]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("IntentsClient",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/pagers.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/pagers.py
new file mode 100644
index 000000000000..1e3f29ddcb52
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/pagers.py
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
+
+from google.cloud.dialogflowcx_v3.types import intent
+
+
+class ListIntentsPager:
+ """A pager for iterating through ``list_intents`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.intent.ListIntentsResponse` object, and
+ provides an ``__iter__`` method to iterate through its
+ ``intents`` field.
+
+ If there are more pages, the ``__iter__`` method will make additional
+ ``ListIntents`` requests and continue to iterate
+ through the ``intents`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.intent.ListIntentsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., intent.ListIntentsResponse],
+ request: intent.ListIntentsRequest,
+ response: intent.ListIntentsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.intent.ListIntentsRequest`):
+ The initial request object.
+ response (:class:`~.intent.ListIntentsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = intent.ListIntentsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ def pages(self) -> Iterable[intent.ListIntentsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __iter__(self) -> Iterable[intent.Intent]:
+ for page in self.pages:
+ yield from page.intents
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
+
+
+class ListIntentsAsyncPager:
+ """A pager for iterating through ``list_intents`` requests.
+
+ This class thinly wraps an initial
+ :class:`~.intent.ListIntentsResponse` object, and
+ provides an ``__aiter__`` method to iterate through its
+ ``intents`` field.
+
+ If there are more pages, the ``__aiter__`` method will make additional
+ ``ListIntents`` requests and continue to iterate
+ through the ``intents`` field on the
+ corresponding responses.
+
+ All the usual :class:`~.intent.ListIntentsResponse`
+ attributes are available on the pager. If multiple requests are made, only
+ the most recent response is retained, and thus used for attribute lookup.
+ """
+
+ def __init__(
+ self,
+ method: Callable[..., Awaitable[intent.ListIntentsResponse]],
+ request: intent.ListIntentsRequest,
+ response: intent.ListIntentsResponse,
+ *,
+ metadata: Sequence[Tuple[str, str]] = ()
+ ):
+ """Instantiate the pager.
+
+ Args:
+ method (Callable): The method that was originally called, and
+ which instantiated this pager.
+ request (:class:`~.intent.ListIntentsRequest`):
+ The initial request object.
+ response (:class:`~.intent.ListIntentsResponse`):
+ The initial response object.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ self._method = method
+ self._request = intent.ListIntentsRequest(request)
+ self._response = response
+ self._metadata = metadata
+
+ def __getattr__(self, name: str) -> Any:
+ return getattr(self._response, name)
+
+ @property
+ async def pages(self) -> AsyncIterable[intent.ListIntentsResponse]:
+ yield self._response
+ while self._response.next_page_token:
+ self._request.page_token = self._response.next_page_token
+ self._response = await self._method(self._request, metadata=self._metadata)
+ yield self._response
+
+ def __aiter__(self) -> AsyncIterable[intent.Intent]:
+ async def async_generator():
+ async for page in self.pages:
+ for response in page.intents:
+ yield response
+
+ return async_generator()
+
+ def __repr__(self) -> str:
+ return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py
new file mode 100644
index 000000000000..ecbfad6b0062
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/__init__.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from typing import Dict, Type
+
+from .base import IntentsTransport
+from .grpc import IntentsGrpcTransport
+from .grpc_asyncio import IntentsGrpcAsyncIOTransport
+
+
+# Compile a registry of transports.
+_transport_registry = OrderedDict() # type: Dict[str, Type[IntentsTransport]]
+_transport_registry["grpc"] = IntentsGrpcTransport
+_transport_registry["grpc_asyncio"] = IntentsGrpcAsyncIOTransport
+
+
+__all__ = (
+ "IntentsTransport",
+ "IntentsGrpcTransport",
+ "IntentsGrpcAsyncIOTransport",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/base.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/base.py
new file mode 100644
index 000000000000..64e82a1eb6b9
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/base.py
@@ -0,0 +1,179 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 abc
+import typing
+import pkg_resources
+
+from google import auth # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import intent
+from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-dialogflowcx",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+class IntentsTransport(abc.ABC):
+ """Abstract transport class for Intents."""
+
+ AUTH_SCOPES = (
+ "https://www.googleapis.com/auth/cloud-platform",
+ "https://www.googleapis.com/auth/dialogflow",
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: typing.Optional[str] = None,
+ scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
+ quota_project_id: typing.Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ **kwargs,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scope (Optional[Sequence[str]]): A list of scopes.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+ """
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
+ if ":" not in host:
+ host += ":443"
+ self._host = host
+
+ # If no credentials are provided, then determine the appropriate
+ # defaults.
+ if credentials and credentials_file:
+ raise exceptions.DuplicateCredentialArgs(
+ "'credentials_file' and 'credentials' are mutually exclusive"
+ )
+
+ if credentials_file is not None:
+ credentials, _ = auth.load_credentials_from_file(
+ credentials_file, scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ elif credentials is None:
+ credentials, _ = auth.default(
+ scopes=scopes, quota_project_id=quota_project_id
+ )
+
+ # Save the credentials.
+ self._credentials = credentials
+
+ # Lifted into its own function so it can be stubbed out during tests.
+ self._prep_wrapped_messages(client_info)
+
+ def _prep_wrapped_messages(self, client_info):
+ # Precompute the wrapped methods.
+ self._wrapped_methods = {
+ self.list_intents: gapic_v1.method.wrap_method(
+ self.list_intents, default_timeout=None, client_info=client_info,
+ ),
+ self.get_intent: gapic_v1.method.wrap_method(
+ self.get_intent, default_timeout=None, client_info=client_info,
+ ),
+ self.create_intent: gapic_v1.method.wrap_method(
+ self.create_intent, default_timeout=None, client_info=client_info,
+ ),
+ self.update_intent: gapic_v1.method.wrap_method(
+ self.update_intent, default_timeout=None, client_info=client_info,
+ ),
+ self.delete_intent: gapic_v1.method.wrap_method(
+ self.delete_intent, default_timeout=None, client_info=client_info,
+ ),
+ }
+
+ @property
+ def list_intents(
+ self,
+ ) -> typing.Callable[
+ [intent.ListIntentsRequest],
+ typing.Union[
+ intent.ListIntentsResponse, typing.Awaitable[intent.ListIntentsResponse]
+ ],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def get_intent(
+ self,
+ ) -> typing.Callable[
+ [intent.GetIntentRequest],
+ typing.Union[intent.Intent, typing.Awaitable[intent.Intent]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def create_intent(
+ self,
+ ) -> typing.Callable[
+ [gcdc_intent.CreateIntentRequest],
+ typing.Union[gcdc_intent.Intent, typing.Awaitable[gcdc_intent.Intent]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def update_intent(
+ self,
+ ) -> typing.Callable[
+ [gcdc_intent.UpdateIntentRequest],
+ typing.Union[gcdc_intent.Intent, typing.Awaitable[gcdc_intent.Intent]],
+ ]:
+ raise NotImplementedError()
+
+ @property
+ def delete_intent(
+ self,
+ ) -> typing.Callable[
+ [intent.DeleteIntentRequest],
+ typing.Union[empty.Empty, typing.Awaitable[empty.Empty]],
+ ]:
+ raise NotImplementedError()
+
+
+__all__ = ("IntentsTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py
new file mode 100644
index 000000000000..41b2a08cec7f
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/grpc.py
@@ -0,0 +1,363 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import grpc_helpers # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import intent
+from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import IntentsTransport, DEFAULT_CLIENT_INFO
+
+
+class IntentsGrpcTransport(IntentsTransport):
+ """gRPC backend transport for Intents.
+
+ Service for managing
+ [Intents][google.cloud.dialogflow.cx.v3.Intent].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _stubs: Dict[str, Callable]
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Sequence[str] = None,
+ channel: grpc.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id: Optional[str] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
+ ignored if ``channel`` is provided.
+ channel (Optional[grpc.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ self._stubs = {} # type: Dict[str, Callable]
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: str = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> grpc.Channel:
+ """Create and return a gRPC channel object.
+ Args:
+ address (Optionsl[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is mutually exclusive with credentials.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ grpc.Channel: A gRPC channel object.
+
+ Raises:
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ @property
+ def grpc_channel(self) -> grpc.Channel:
+ """Return the channel designed to connect to this service.
+ """
+ return self._grpc_channel
+
+ @property
+ def list_intents(
+ self,
+ ) -> Callable[[intent.ListIntentsRequest], intent.ListIntentsResponse]:
+ r"""Return a callable for the list intents method over gRPC.
+
+ Returns the list of all intents in the specified
+ agent.
+
+ Returns:
+ Callable[[~.ListIntentsRequest],
+ ~.ListIntentsResponse]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_intents" not in self._stubs:
+ self._stubs["list_intents"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/ListIntents",
+ request_serializer=intent.ListIntentsRequest.serialize,
+ response_deserializer=intent.ListIntentsResponse.deserialize,
+ )
+ return self._stubs["list_intents"]
+
+ @property
+ def get_intent(self) -> Callable[[intent.GetIntentRequest], intent.Intent]:
+ r"""Return a callable for the get intent method over gRPC.
+
+ Retrieves the specified intent.
+
+ Returns:
+ Callable[[~.GetIntentRequest],
+ ~.Intent]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_intent" not in self._stubs:
+ self._stubs["get_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/GetIntent",
+ request_serializer=intent.GetIntentRequest.serialize,
+ response_deserializer=intent.Intent.deserialize,
+ )
+ return self._stubs["get_intent"]
+
+ @property
+ def create_intent(
+ self,
+ ) -> Callable[[gcdc_intent.CreateIntentRequest], gcdc_intent.Intent]:
+ r"""Return a callable for the create intent method over gRPC.
+
+ Creates an intent in the specified agent.
+
+ Returns:
+ Callable[[~.CreateIntentRequest],
+ ~.Intent]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_intent" not in self._stubs:
+ self._stubs["create_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/CreateIntent",
+ request_serializer=gcdc_intent.CreateIntentRequest.serialize,
+ response_deserializer=gcdc_intent.Intent.deserialize,
+ )
+ return self._stubs["create_intent"]
+
+ @property
+ def update_intent(
+ self,
+ ) -> Callable[[gcdc_intent.UpdateIntentRequest], gcdc_intent.Intent]:
+ r"""Return a callable for the update intent method over gRPC.
+
+ Updates the specified intent.
+
+ Returns:
+ Callable[[~.UpdateIntentRequest],
+ ~.Intent]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_intent" not in self._stubs:
+ self._stubs["update_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/UpdateIntent",
+ request_serializer=gcdc_intent.UpdateIntentRequest.serialize,
+ response_deserializer=gcdc_intent.Intent.deserialize,
+ )
+ return self._stubs["update_intent"]
+
+ @property
+ def delete_intent(self) -> Callable[[intent.DeleteIntentRequest], empty.Empty]:
+ r"""Return a callable for the delete intent method over gRPC.
+
+ Deletes the specified intent.
+
+ Returns:
+ Callable[[~.DeleteIntentRequest],
+ ~.Empty]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_intent" not in self._stubs:
+ self._stubs["delete_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/DeleteIntent",
+ request_serializer=intent.DeleteIntentRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_intent"]
+
+
+__all__ = ("IntentsGrpcTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py
new file mode 100644
index 000000000000..a0b3dd563831
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/intents/transports/grpc_asyncio.py
@@ -0,0 +1,371 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT 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 warnings
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import grpc_helpers_async # type: ignore
+from google import auth # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+
+import grpc # type: ignore
+from grpc.experimental import aio # type: ignore
+
+from google.cloud.dialogflowcx_v3.types import intent
+from google.cloud.dialogflowcx_v3.types import intent as gcdc_intent
+from google.protobuf import empty_pb2 as empty # type: ignore
+
+from .base import IntentsTransport, DEFAULT_CLIENT_INFO
+from .grpc import IntentsGrpcTransport
+
+
+class IntentsGrpcAsyncIOTransport(IntentsTransport):
+ """gRPC AsyncIO backend transport for Intents.
+
+ Service for managing
+ [Intents][google.cloud.dialogflow.cx.v3.Intent].
+
+ This class defines the same methods as the primary client, so the
+ primary client can load the underlying transport implementation
+ and call it.
+
+ It sends protocol buffers over the wire using gRPC (which is built on
+ top of HTTP/2); the ``grpcio`` package must be installed.
+ """
+
+ _grpc_channel: aio.Channel
+ _stubs: Dict[str, Callable] = {}
+
+ @classmethod
+ def create_channel(
+ cls,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
+ **kwargs,
+ ) -> aio.Channel:
+ """Create and return a gRPC AsyncIO channel object.
+ Args:
+ address (Optional[str]): The host for the channel to use.
+ credentials (Optional[~.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify this application to the service. If
+ none are specified, the client will attempt to ascertain
+ the credentials from the environment.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
+ channel creation.
+ Returns:
+ aio.Channel: A gRPC AsyncIO channel object.
+ """
+ scopes = scopes or cls.AUTH_SCOPES
+ return grpc_helpers_async.create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes,
+ quota_project_id=quota_project_id,
+ **kwargs,
+ )
+
+ def __init__(
+ self,
+ *,
+ host: str = "dialogflow.googleapis.com",
+ credentials: credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: aio.Channel = None,
+ api_mtls_endpoint: str = None,
+ client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
+ ssl_channel_credentials: grpc.ChannelCredentials = None,
+ quota_project_id=None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the transport.
+
+ Args:
+ host (Optional[str]): The hostname to connect to.
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ This argument is ignored if ``channel`` is provided.
+ credentials_file (Optional[str]): A file with credentials that can
+ be loaded with :func:`google.auth.load_credentials_from_file`.
+ This argument is ignored if ``channel`` is provided.
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
+ service. These are only used when credentials are not specified and
+ are passed to :func:`google.auth.default`.
+ channel (Optional[aio.Channel]): A ``Channel`` instance through
+ which to make calls.
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
+ If provided, it overrides the ``host`` argument and tries to create
+ a mutual TLS channel with client SSL credentials from
+ ``client_cert_source`` or applicatin default SSL credentials.
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
+ Deprecated. A callback to provide client SSL certificate bytes and
+ private key bytes, both in PEM format. It is ignored if
+ ``api_mtls_endpoint`` is None.
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
+ for grpc channel. It is ignored if ``channel`` is provided.
+ quota_project_id (Optional[str]): An optional project to use for billing
+ and quota.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
+ and ``credentials_file`` are passed.
+ """
+ self._ssl_channel_credentials = ssl_channel_credentials
+
+ if channel:
+ # Sanity check: Ensure that channel and credentials are not both
+ # provided.
+ credentials = False
+
+ # If a channel was explicitly provided, set it.
+ self._grpc_channel = channel
+ self._ssl_channel_credentials = None
+ elif api_mtls_endpoint:
+ warnings.warn(
+ "api_mtls_endpoint and client_cert_source are deprecated",
+ DeprecationWarning,
+ )
+
+ host = (
+ api_mtls_endpoint
+ if ":" in api_mtls_endpoint
+ else api_mtls_endpoint + ":443"
+ )
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # Create SSL credentials with client_cert_source or application
+ # default SSL credentials.
+ if client_cert_source:
+ cert, key = client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ else:
+ ssl_credentials = SslCredentials().ssl_credentials
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+ self._ssl_channel_credentials = ssl_credentials
+ else:
+ host = host if ":" in host else host + ":443"
+
+ if credentials is None:
+ credentials, _ = auth.default(
+ scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
+ )
+
+ # create a new channel. The provided one is ignored.
+ self._grpc_channel = type(self).create_channel(
+ host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ ssl_credentials=ssl_channel_credentials,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ )
+
+ # Run the base constructor.
+ super().__init__(
+ host=host,
+ credentials=credentials,
+ credentials_file=credentials_file,
+ scopes=scopes or self.AUTH_SCOPES,
+ quota_project_id=quota_project_id,
+ client_info=client_info,
+ )
+
+ self._stubs = {}
+
+ @property
+ def grpc_channel(self) -> aio.Channel:
+ """Create the channel designed to connect to this service.
+
+ This property caches on the instance; repeated calls return
+ the same channel.
+ """
+ # Return the channel from cache.
+ return self._grpc_channel
+
+ @property
+ def list_intents(
+ self,
+ ) -> Callable[[intent.ListIntentsRequest], Awaitable[intent.ListIntentsResponse]]:
+ r"""Return a callable for the list intents method over gRPC.
+
+ Returns the list of all intents in the specified
+ agent.
+
+ Returns:
+ Callable[[~.ListIntentsRequest],
+ Awaitable[~.ListIntentsResponse]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "list_intents" not in self._stubs:
+ self._stubs["list_intents"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/ListIntents",
+ request_serializer=intent.ListIntentsRequest.serialize,
+ response_deserializer=intent.ListIntentsResponse.deserialize,
+ )
+ return self._stubs["list_intents"]
+
+ @property
+ def get_intent(
+ self,
+ ) -> Callable[[intent.GetIntentRequest], Awaitable[intent.Intent]]:
+ r"""Return a callable for the get intent method over gRPC.
+
+ Retrieves the specified intent.
+
+ Returns:
+ Callable[[~.GetIntentRequest],
+ Awaitable[~.Intent]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "get_intent" not in self._stubs:
+ self._stubs["get_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/GetIntent",
+ request_serializer=intent.GetIntentRequest.serialize,
+ response_deserializer=intent.Intent.deserialize,
+ )
+ return self._stubs["get_intent"]
+
+ @property
+ def create_intent(
+ self,
+ ) -> Callable[[gcdc_intent.CreateIntentRequest], Awaitable[gcdc_intent.Intent]]:
+ r"""Return a callable for the create intent method over gRPC.
+
+ Creates an intent in the specified agent.
+
+ Returns:
+ Callable[[~.CreateIntentRequest],
+ Awaitable[~.Intent]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "create_intent" not in self._stubs:
+ self._stubs["create_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/CreateIntent",
+ request_serializer=gcdc_intent.CreateIntentRequest.serialize,
+ response_deserializer=gcdc_intent.Intent.deserialize,
+ )
+ return self._stubs["create_intent"]
+
+ @property
+ def update_intent(
+ self,
+ ) -> Callable[[gcdc_intent.UpdateIntentRequest], Awaitable[gcdc_intent.Intent]]:
+ r"""Return a callable for the update intent method over gRPC.
+
+ Updates the specified intent.
+
+ Returns:
+ Callable[[~.UpdateIntentRequest],
+ Awaitable[~.Intent]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "update_intent" not in self._stubs:
+ self._stubs["update_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/UpdateIntent",
+ request_serializer=gcdc_intent.UpdateIntentRequest.serialize,
+ response_deserializer=gcdc_intent.Intent.deserialize,
+ )
+ return self._stubs["update_intent"]
+
+ @property
+ def delete_intent(
+ self,
+ ) -> Callable[[intent.DeleteIntentRequest], Awaitable[empty.Empty]]:
+ r"""Return a callable for the delete intent method over gRPC.
+
+ Deletes the specified intent.
+
+ Returns:
+ Callable[[~.DeleteIntentRequest],
+ Awaitable[~.Empty]]:
+ A function that, when called, will call the underlying RPC
+ on the server.
+ """
+ # Generate a "stub function" on-the-fly which will actually make
+ # the request.
+ # gRPC handles serialization and deserialization, so we just need
+ # to pass in the functions for each.
+ if "delete_intent" not in self._stubs:
+ self._stubs["delete_intent"] = self.grpc_channel.unary_unary(
+ "/google.cloud.dialogflow.cx.v3.Intents/DeleteIntent",
+ request_serializer=intent.DeleteIntentRequest.serialize,
+ response_deserializer=empty.Empty.FromString,
+ )
+ return self._stubs["delete_intent"]
+
+
+__all__ = ("IntentsGrpcAsyncIOTransport",)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/pages/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/pages/__init__.py
new file mode 100644
index 000000000000..4fff3f522131
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/pages/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from .client import PagesClient
+from .async_client import PagesAsyncClient
+
+__all__ = (
+ "PagesClient",
+ "PagesAsyncClient",
+)
diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/pages/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/pages/async_client.py
new file mode 100644
index 000000000000..3a900c6fce0c
--- /dev/null
+++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/pages/async_client.py
@@ -0,0 +1,597 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.cloud.dialogflowcx_v3.services.pages import pagers
+from google.cloud.dialogflowcx_v3.types import fulfillment
+from google.cloud.dialogflowcx_v3.types import page
+from google.cloud.dialogflowcx_v3.types import page as gcdc_page
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+
+from .transports.base import PagesTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import PagesGrpcAsyncIOTransport
+from .client import PagesClient
+
+
+class PagesAsyncClient:
+ """Service for managing [Pages][google.cloud.dialogflow.cx.v3.Page]."""
+
+ _client: PagesClient
+
+ DEFAULT_ENDPOINT = PagesClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = PagesClient.DEFAULT_MTLS_ENDPOINT
+
+ entity_type_path = staticmethod(PagesClient.entity_type_path)
+ parse_entity_type_path = staticmethod(PagesClient.parse_entity_type_path)
+ flow_path = staticmethod(PagesClient.flow_path)
+ parse_flow_path = staticmethod(PagesClient.parse_flow_path)
+ intent_path = staticmethod(PagesClient.intent_path)
+ parse_intent_path = staticmethod(PagesClient.parse_intent_path)
+ page_path = staticmethod(PagesClient.page_path)
+ parse_page_path = staticmethod(PagesClient.parse_page_path)
+ transition_route_group_path = staticmethod(PagesClient.transition_route_group_path)
+ parse_transition_route_group_path = staticmethod(
+ PagesClient.parse_transition_route_group_path
+ )
+ webhook_path = staticmethod(PagesClient.webhook_path)
+ parse_webhook_path = staticmethod(PagesClient.parse_webhook_path)
+
+ common_billing_account_path = staticmethod(PagesClient.common_billing_account_path)
+ parse_common_billing_account_path = staticmethod(
+ PagesClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(PagesClient.common_folder_path)
+ parse_common_folder_path = staticmethod(PagesClient.parse_common_folder_path)
+
+ common_organization_path = staticmethod(PagesClient.common_organization_path)
+ parse_common_organization_path = staticmethod(
+ PagesClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(PagesClient.common_project_path)
+ parse_common_project_path = staticmethod(PagesClient.parse_common_project_path)
+
+ common_location_path = staticmethod(PagesClient.common_location_path)
+ parse_common_location_path = staticmethod(PagesClient.parse_common_location_path)
+
+ from_service_account_file = PagesClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> PagesTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ PagesTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(PagesClient).get_transport_class, type(PagesClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, PagesTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the pages client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.PagesTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = PagesClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def list_pages(
+ self,
+ request: page.ListPagesRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListPagesAsyncPager:
+ r"""Returns the list of all pages in the specified flow.
+
+ Args:
+ request (:class:`~.page.ListPagesRequest`):
+ The request object. The request message for
+ [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages].
+ parent (:class:`str`):
+ Required. The flow to list all pages for. Format:
+ ``projects//locations//agents//flows/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListPagesAsyncPager:
+ The response message for
+ [Pages.ListPages][google.cloud.dialogflow.cx.v3.Pages.ListPages].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity 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:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = page.ListPagesRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_pages,
+ default_timeout=None,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListPagesAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_page(
+ self,
+ request: page.GetPageRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> page.Page:
+ r"""Retrieves the specified page.
+
+ Args:
+ request (:class:`~.page.GetPageRequest`):
+ The request object. The request message for
+ [Pages.GetPage][google.cloud.dialogflow.cx.v3.Pages.GetPage].
+ name (:class:`str`):
+ Required. The name of the page. Format:
+ ``projects//locations/