From 4e3426f318f43306b446e9e49dcc6869dfec27c5 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 1 Aug 2021 10:10:25 +0000 Subject: [PATCH] feat(v3): add advanced settings for agent level (#137) PiperOrigin-RevId: 387850898 Source-Link: https://github.com/googleapis/googleapis/commit/05d477b7c301002f77b830502cc1514ef63cf68d Source-Link: https://github.com/googleapis/googleapis-gen/commit/6982a6f5d3709f4e863918d3e09fa1c7d35163b7 feat(v3): add rollout config, state and failure reason for experiment feat(v3): add insights export settings for security setting feat(v3): add language code for streaming recognition result and flow versions for query parameters docs(v3): deprecate legacy logging settings --- .../google/cloud/dialogflowcx/__init__.py | 6 ++ .../google/cloud/dialogflowcx_v3/__init__.py | 6 ++ .../services/agents/async_client.py | 1 + .../dialogflowcx_v3/services/agents/client.py | 1 + .../services/sessions/async_client.py | 2 + .../services/sessions/client.py | 18 ++++ .../cloud/dialogflowcx_v3/types/__init__.py | 6 ++ .../types/advanced_settings.py | 57 ++++++++++++ .../cloud/dialogflowcx_v3/types/agent.py | 17 +++- .../cloud/dialogflowcx_v3/types/experiment.py | 92 ++++++++++++++++++- .../types/security_settings.py | 28 +++++- .../cloud/dialogflowcx_v3/types/session.py | 12 +++ .../unit/gapic/dialogflowcx_v3/test_agents.py | 1 + .../gapic/dialogflowcx_v3/test_experiments.py | 20 ++++ .../gapic/dialogflowcx_v3/test_sessions.py | 64 +++++++++---- 15 files changed, 306 insertions(+), 25 deletions(-) create mode 100644 packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/advanced_settings.py 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 ac14d06b4706..6d6520fd689e 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx/__init__.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx/__init__.py @@ -71,6 +71,7 @@ WebhooksAsyncClient, ) +from google.cloud.dialogflowcx_v3.types.advanced_settings import AdvancedSettings from google.cloud.dialogflowcx_v3.types.agent import Agent from google.cloud.dialogflowcx_v3.types.agent import AgentValidationResult from google.cloud.dialogflowcx_v3.types.agent import CreateAgentRequest @@ -130,6 +131,8 @@ from google.cloud.dialogflowcx_v3.types.experiment import GetExperimentRequest from google.cloud.dialogflowcx_v3.types.experiment import ListExperimentsRequest from google.cloud.dialogflowcx_v3.types.experiment import ListExperimentsResponse +from google.cloud.dialogflowcx_v3.types.experiment import RolloutConfig +from google.cloud.dialogflowcx_v3.types.experiment import RolloutState from google.cloud.dialogflowcx_v3.types.experiment import StartExperimentRequest from google.cloud.dialogflowcx_v3.types.experiment import StopExperimentRequest from google.cloud.dialogflowcx_v3.types.experiment import UpdateExperimentRequest @@ -335,6 +338,7 @@ "VersionsAsyncClient", "WebhooksClient", "WebhooksAsyncClient", + "AdvancedSettings", "Agent", "AgentValidationResult", "CreateAgentRequest", @@ -386,6 +390,8 @@ "GetExperimentRequest", "ListExperimentsRequest", "ListExperimentsResponse", + "RolloutConfig", + "RolloutState", "StartExperimentRequest", "StopExperimentRequest", "UpdateExperimentRequest", 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 index b89fa4264a22..6ce4a51b0293 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/__init__.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/__init__.py @@ -43,6 +43,7 @@ from .services.webhooks import WebhooksClient from .services.webhooks import WebhooksAsyncClient +from .types.advanced_settings import AdvancedSettings from .types.agent import Agent from .types.agent import AgentValidationResult from .types.agent import CreateAgentRequest @@ -94,6 +95,8 @@ from .types.experiment import GetExperimentRequest from .types.experiment import ListExperimentsRequest from .types.experiment import ListExperimentsResponse +from .types.experiment import RolloutConfig +from .types.experiment import RolloutState from .types.experiment import StartExperimentRequest from .types.experiment import StopExperimentRequest from .types.experiment import UpdateExperimentRequest @@ -247,6 +250,7 @@ "TransitionRouteGroupsAsyncClient", "VersionsAsyncClient", "WebhooksAsyncClient", + "AdvancedSettings", "Agent", "AgentValidationResult", "AgentsClient", @@ -386,6 +390,8 @@ "ResourceName", "ResponseMessage", "RestoreAgentRequest", + "RolloutConfig", + "RolloutState", "RunContinuousTestMetadata", "RunContinuousTestRequest", "RunContinuousTestResponse", 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 index 89a55c6b6ab3..8203dcd1b878 100644 --- 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 @@ -29,6 +29,7 @@ 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 advanced_settings from google.cloud.dialogflowcx_v3.types import agent from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent from google.cloud.dialogflowcx_v3.types import flow 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 index 9de9494b90fc..b4b7d424e9b2 100644 --- 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 @@ -33,6 +33,7 @@ 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 advanced_settings from google.cloud.dialogflowcx_v3.types import agent from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent from google.cloud.dialogflowcx_v3.types import flow diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/async_client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/async_client.py index 7257e79752be..22e155a869e3 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/async_client.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/async_client.py @@ -75,6 +75,8 @@ class SessionsAsyncClient: parse_transition_route_group_path = staticmethod( SessionsClient.parse_transition_route_group_path ) + version_path = staticmethod(SessionsClient.version_path) + parse_version_path = staticmethod(SessionsClient.parse_version_path) webhook_path = staticmethod(SessionsClient.webhook_path) parse_webhook_path = staticmethod(SessionsClient.parse_webhook_path) common_billing_account_path = staticmethod( diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/client.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/client.py index 121e8403227d..7236c9808f69 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/client.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/services/sessions/client.py @@ -296,6 +296,24 @@ def parse_transition_route_group_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def version_path( + project: str, location: str, agent: str, flow: str, version: str, + ) -> str: + """Returns 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]: + """Parses 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 webhook_path(project: str, location: str, agent: str, webhook: str,) -> str: """Returns a fully-qualified webhook string.""" diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/__init__.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/__init__.py index c083e5b64a56..b0518a2d8db7 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/__init__.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/__init__.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from .advanced_settings import AdvancedSettings from .agent import ( Agent, AgentValidationResult, @@ -73,6 +74,8 @@ GetExperimentRequest, ListExperimentsRequest, ListExperimentsResponse, + RolloutConfig, + RolloutState, StartExperimentRequest, StopExperimentRequest, UpdateExperimentRequest, @@ -235,6 +238,7 @@ ) __all__ = ( + "AdvancedSettings", "Agent", "AgentValidationResult", "CreateAgentRequest", @@ -286,6 +290,8 @@ "GetExperimentRequest", "ListExperimentsRequest", "ListExperimentsResponse", + "RolloutConfig", + "RolloutState", "StartExperimentRequest", "StopExperimentRequest", "UpdateExperimentRequest", diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/advanced_settings.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/advanced_settings.py new file mode 100644 index 000000000000..37f9bff0d33d --- /dev/null +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/advanced_settings.py @@ -0,0 +1,57 @@ +# -*- 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 proto # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.dialogflow.cx.v3", manifest={"AdvancedSettings",}, +) + + +class AdvancedSettings(proto.Message): + r"""Hierarchical advanced settings for + agent/flow/page/fulfillment/parameter. Settings exposed at lower + level overrides the settings exposed at higher level. + + Hierarchy: Agent->Flow->Page->Fulfillment/Parameter. + + Attributes: + logging_settings (google.cloud.dialogflowcx_v3.types.AdvancedSettings.LoggingSettings): + Settings for logging. + Settings for Dialogflow History, Contact Center + messages, StackDriver logs, and speech logging. + Exposed at the following levels: + - Agent level. + """ + + class LoggingSettings(proto.Message): + r"""Define behaviors on logging. + Attributes: + enable_stackdriver_logging (bool): + If true, StackDriver logging is currently + enabled. + enable_interaction_logging (bool): + If true, DF Interaction logging is currently + enabled. + """ + + enable_stackdriver_logging = proto.Field(proto.BOOL, number=2,) + enable_interaction_logging = proto.Field(proto.BOOL, number=3,) + + logging_settings = proto.Field(proto.MESSAGE, number=6, message=LoggingSettings,) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/agent.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/agent.py index 2bdab12a817d..25abac22824f 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/agent.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/agent.py @@ -15,6 +15,9 @@ # import proto # type: ignore +from google.cloud.dialogflowcx_v3.types import ( + advanced_settings as gcdc_advanced_settings, +) from google.cloud.dialogflowcx_v3.types import flow from google.protobuf import field_mask_pb2 # type: ignore @@ -114,11 +117,18 @@ class Agent(proto.Message): reference for the agent. Format: ``projects//locations//securitySettings/``. enable_stackdriver_logging (bool): - Indicates if stackdriver logging is enabled - for the agent. + Indicates if stackdriver logging is enabled for the agent. + Please use + [agent.advanced_settings][google.cloud.dialogflow.cx.v3.AdvancedSettings.LoggingSettings] + instead. enable_spell_correction (bool): Indicates if automatic spell correction is enabled in detect intent requests. + advanced_settings (google.cloud.dialogflowcx_v3.types.AdvancedSettings): + Hierarchical advanced settings for this + agent. The settings exposed at the lower level + overrides the settings exposed at the higher + level. """ name = proto.Field(proto.STRING, number=1,) @@ -135,6 +145,9 @@ class Agent(proto.Message): security_settings = proto.Field(proto.STRING, number=17,) enable_stackdriver_logging = proto.Field(proto.BOOL, number=18,) enable_spell_correction = proto.Field(proto.BOOL, number=20,) + advanced_settings = proto.Field( + proto.MESSAGE, number=22, message=gcdc_advanced_settings.AdvancedSettings, + ) class ListAgentsRequest(proto.Message): diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/experiment.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/experiment.py index 95f3eaa2e4ec..698b1dd90d47 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/experiment.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/experiment.py @@ -26,6 +26,8 @@ "Experiment", "VersionVariants", "VariantsHistory", + "RolloutConfig", + "RolloutState", "ListExperimentsRequest", "ListExperimentsResponse", "GetExperimentRequest", @@ -57,12 +59,26 @@ class Experiment(proto.Message): state (google.cloud.dialogflowcx_v3.types.Experiment.State): The current state of the experiment. Transition triggered by - Expriments.StartExperiment: PENDING->RUNNING. + Experiments.StartExperiment: DRAFT->RUNNING. Transition triggered by - Expriments.CancelExperiment: PENDING->CANCELLED - or RUNNING->CANCELLED. + Experiments.CancelExperiment: DRAFT->DONE or + RUNNING->DONE. definition (google.cloud.dialogflowcx_v3.types.Experiment.Definition): The definition of the experiment. + rollout_config (google.cloud.dialogflowcx_v3.types.RolloutConfig): + The configuration for auto rollout. If set, + there should be exactly two variants in the + experiment (control variant being the default + version of the flow), the traffic allocation for + the non-control variant will gradually increase + to 100% when conditions are met, and eventually + replace the control variant to become the + default version of the flow. + rollout_state (google.cloud.dialogflowcx_v3.types.RolloutState): + State of the auto rollout process. + rollout_failure_reason (str): + The reason why rollout has failed. Should only be set when + state is ROLLOUT_FAILED. result (google.cloud.dialogflowcx_v3.types.Experiment.Result): Inference result of the experiment. create_time (google.protobuf.timestamp_pb2.Timestamp): @@ -90,6 +106,7 @@ class State(proto.Enum): DRAFT = 1 RUNNING = 2 DONE = 3 + ROLLOUT_FAILED = 4 class Definition(proto.Message): r"""Definition of the experiment. @@ -225,6 +242,9 @@ class VersionMetrics(proto.Message): description = proto.Field(proto.STRING, number=3,) state = proto.Field(proto.ENUM, number=4, enum=State,) definition = proto.Field(proto.MESSAGE, number=5, message=Definition,) + rollout_config = proto.Field(proto.MESSAGE, number=14, message="RolloutConfig",) + rollout_state = proto.Field(proto.MESSAGE, number=15, message="RolloutState",) + rollout_failure_reason = proto.Field(proto.STRING, number=16,) result = proto.Field(proto.MESSAGE, number=6, message=Result,) create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) start_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) @@ -283,6 +303,72 @@ class VariantsHistory(proto.Message): update_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) +class RolloutConfig(proto.Message): + r"""The configuration for auto rollout. + Attributes: + rollout_steps (Sequence[google.cloud.dialogflowcx_v3.types.RolloutConfig.RolloutStep]): + Steps to roll out a flow version. Steps + should be sorted by percentage in ascending + order. + rollout_condition (str): + The conditions that are used to evaluate the success of a + rollout step. If not specified, all rollout steps will + proceed to the next one unless failure conditions are met. + E.g. "containment_rate > 60% AND callback_rate < 20%". See + the `conditions + reference `__. + failure_condition (str): + The conditions that are used to evaluate the failure of a + rollout step. If not specified, no rollout steps will fail. + E.g. "containment_rate < 10% OR average_turn_count < 3". See + the `conditions + reference `__. + """ + + class RolloutStep(proto.Message): + r"""A single rollout step with specified traffic allocation. + Attributes: + display_name (str): + The name of the rollout step; + traffic_percent (int): + The percentage of traffic allocated to the flow version of + this rollout step. (0%, 100%]. + min_duration (google.protobuf.duration_pb2.Duration): + The minimum time that this step should last. + Should be longer than 1 hour. If not set, the + default minimum duration for each step will be 1 + hour. + """ + + display_name = proto.Field(proto.STRING, number=1,) + traffic_percent = proto.Field(proto.INT32, number=2,) + min_duration = proto.Field( + proto.MESSAGE, number=3, message=duration_pb2.Duration, + ) + + rollout_steps = proto.RepeatedField(proto.MESSAGE, number=1, message=RolloutStep,) + rollout_condition = proto.Field(proto.STRING, number=2,) + failure_condition = proto.Field(proto.STRING, number=3,) + + +class RolloutState(proto.Message): + r"""State of the auto-rollout process. + Attributes: + step (str): + Display name of the current auto rollout + step. + step_index (int): + Index of the current step in the auto rollout + steps list. + start_time (google.protobuf.timestamp_pb2.Timestamp): + Start time of the current step. + """ + + step = proto.Field(proto.STRING, number=1,) + step_index = proto.Field(proto.INT32, number=3,) + start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + + class ListExperimentsRequest(proto.Message): r"""The request message for [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments]. diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/security_settings.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/security_settings.py index 4dec351ecc8c..7b0e1bfff001 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/security_settings.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/security_settings.py @@ -159,8 +159,8 @@ class SecuritySettings(proto.Message): it does not have access to – for example, Cloud logging. inspect_template (str): - DLP inspect template name. Use this template to define - inspect base settings. + `DLP `__ inspect template + name. Use this template to define inspect base settings. If empty, we use the default DLP inspect config. @@ -185,6 +185,14 @@ class SecuritySettings(proto.Message): purge_data_types (Sequence[google.cloud.dialogflowcx_v3.types.SecuritySettings.PurgeDataType]): List of types of data to remove when retention settings triggers purge. + insights_export_settings (google.cloud.dialogflowcx_v3.types.SecuritySettings.InsightsExportSettings): + Optional. Controls conversation exporting settings to + Insights after conversation is completed. + + If + [retention_strategy][google.cloud.dialogflow.cx.v3.SecuritySettings.retention_strategy] + is set to REMOVE_AFTER_CONVERSATION, Insights export is + disabled no matter what you configure here. """ class RedactionStrategy(proto.Enum): @@ -204,6 +212,19 @@ class PurgeDataType(proto.Enum): PURGE_DATA_TYPE_UNSPECIFIED = 0 DIALOGFLOW_HISTORY = 1 + class InsightsExportSettings(proto.Message): + r"""Settings for exporting conversations to + `Insights `__. + + Attributes: + enable_insights_export (bool): + If enabled, we will automatically exports + conversations to Insights and Insights runs its + analyzers. + """ + + enable_insights_export = proto.Field(proto.BOOL, number=1,) + name = proto.Field(proto.STRING, number=1,) display_name = proto.Field(proto.STRING, number=2,) redaction_strategy = proto.Field(proto.ENUM, number=3, enum=RedactionStrategy,) @@ -211,6 +232,9 @@ class PurgeDataType(proto.Enum): inspect_template = proto.Field(proto.STRING, number=9,) retention_window_days = proto.Field(proto.INT32, number=6, oneof="data_retention",) purge_data_types = proto.RepeatedField(proto.ENUM, number=8, enum=PurgeDataType,) + insights_export_settings = proto.Field( + proto.MESSAGE, number=13, message=InsightsExportSettings, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/session.py b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/session.py index c58f4ef31e2e..102c175d2e16 100644 --- a/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/session.py +++ b/packages/google-cloud-dialogflow-cx/google/cloud/dialogflowcx_v3/types/session.py @@ -331,6 +331,8 @@ class StreamingRecognitionResult(proto.Message): Time offset of the end of this Speech recognition result relative to the beginning of the audio. Only populated for ``message_type`` = ``TRANSCRIPT``. + language_code (str): + Detected language code for the transcript. """ class MessageType(proto.Enum): @@ -350,6 +352,7 @@ class MessageType(proto.Enum): speech_end_offset = proto.Field( proto.MESSAGE, number=8, message=duration_pb2.Duration, ) + language_code = proto.Field(proto.STRING, number=10,) class QueryParameters(proto.Message): @@ -447,6 +450,14 @@ class QueryParameters(proto.Message): Length", "Connection", "From", "User-Agent", "Accept-Encoding", "If-Modified-Since", "If- None-Match", "X-Forwarded-For", etc. + flow_versions (Sequence[str]): + A list of flow versions to override for the request. Format: + ``projects//locations//agents//flows//versions/``. + + If version 1 of flow X is included in this list, the traffic + of flow X will go through version 1 regardless of the + version configuration in the environment. Each flow can have + at most one version specified in this list. """ time_zone = proto.Field(proto.STRING, number=1,) @@ -460,6 +471,7 @@ class QueryParameters(proto.Message): disable_webhook = proto.Field(proto.BOOL, number=7,) analyze_query_text_sentiment = proto.Field(proto.BOOL, number=8,) webhook_headers = proto.MapField(proto.STRING, proto.STRING, number=10,) + flow_versions = proto.RepeatedField(proto.STRING, number=14,) class QueryInput(proto.Message): diff --git a/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_agents.py b/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_agents.py index aa167f8f77f1..95b1fed1281f 100644 --- a/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_agents.py +++ b/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_agents.py @@ -41,6 +41,7 @@ from google.cloud.dialogflowcx_v3.services.agents.transports.base import ( _GOOGLE_AUTH_VERSION, ) +from google.cloud.dialogflowcx_v3.types import advanced_settings from google.cloud.dialogflowcx_v3.types import agent from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent from google.cloud.dialogflowcx_v3.types import flow diff --git a/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_experiments.py b/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_experiments.py index 1831046136d9..665e4d1e288b 100644 --- a/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_experiments.py +++ b/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_experiments.py @@ -840,6 +840,7 @@ def test_get_experiment( display_name="display_name_value", description="description_value", state=experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) response = client.get_experiment(request) @@ -854,6 +855,7 @@ def test_get_experiment( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" def test_get_experiment_from_dict(): @@ -896,6 +898,7 @@ async def test_get_experiment_async( display_name="display_name_value", description="description_value", state=experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) ) response = await client.get_experiment(request) @@ -911,6 +914,7 @@ async def test_get_experiment_async( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" @pytest.mark.asyncio @@ -1054,6 +1058,7 @@ def test_create_experiment( display_name="display_name_value", description="description_value", state=gcdc_experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) response = client.create_experiment(request) @@ -1068,6 +1073,7 @@ def test_create_experiment( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == gcdc_experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" def test_create_experiment_from_dict(): @@ -1115,6 +1121,7 @@ async def test_create_experiment_async( display_name="display_name_value", description="description_value", state=gcdc_experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) ) response = await client.create_experiment(request) @@ -1130,6 +1137,7 @@ async def test_create_experiment_async( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == gcdc_experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" @pytest.mark.asyncio @@ -1293,6 +1301,7 @@ def test_update_experiment( display_name="display_name_value", description="description_value", state=gcdc_experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) response = client.update_experiment(request) @@ -1307,6 +1316,7 @@ def test_update_experiment( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == gcdc_experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" def test_update_experiment_from_dict(): @@ -1354,6 +1364,7 @@ async def test_update_experiment_async( display_name="display_name_value", description="description_value", state=gcdc_experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) ) response = await client.update_experiment(request) @@ -1369,6 +1380,7 @@ async def test_update_experiment_async( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == gcdc_experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" @pytest.mark.asyncio @@ -1736,6 +1748,7 @@ def test_start_experiment( display_name="display_name_value", description="description_value", state=experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) response = client.start_experiment(request) @@ -1750,6 +1763,7 @@ def test_start_experiment( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" def test_start_experiment_from_dict(): @@ -1792,6 +1806,7 @@ async def test_start_experiment_async( display_name="display_name_value", description="description_value", state=experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) ) response = await client.start_experiment(request) @@ -1807,6 +1822,7 @@ async def test_start_experiment_async( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" @pytest.mark.asyncio @@ -1948,6 +1964,7 @@ def test_stop_experiment( display_name="display_name_value", description="description_value", state=experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) response = client.stop_experiment(request) @@ -1962,6 +1979,7 @@ def test_stop_experiment( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" def test_stop_experiment_from_dict(): @@ -2004,6 +2022,7 @@ async def test_stop_experiment_async( display_name="display_name_value", description="description_value", state=experiment.Experiment.State.DRAFT, + rollout_failure_reason="rollout_failure_reason_value", ) ) response = await client.stop_experiment(request) @@ -2019,6 +2038,7 @@ async def test_stop_experiment_async( assert response.display_name == "display_name_value" assert response.description == "description_value" assert response.state == experiment.Experiment.State.DRAFT + assert response.rollout_failure_reason == "rollout_failure_reason_value" @pytest.mark.asyncio diff --git a/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_sessions.py b/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_sessions.py index 0649e4bcbb6c..7fb7a44ff73e 100644 --- a/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_sessions.py +++ b/packages/google-cloud-dialogflow-cx/tests/unit/gapic/dialogflowcx_v3/test_sessions.py @@ -1614,11 +1614,39 @@ def test_parse_transition_route_group_path(): assert expected == actual -def test_webhook_path(): +def test_version_path(): project = "whelk" location = "octopus" agent = "oyster" - webhook = "nudibranch" + flow = "nudibranch" + version = "cuttlefish" + expected = "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format( + project=project, location=location, agent=agent, flow=flow, version=version, + ) + actual = SessionsClient.version_path(project, location, agent, flow, version) + assert expected == actual + + +def test_parse_version_path(): + expected = { + "project": "mussel", + "location": "winkle", + "agent": "nautilus", + "flow": "scallop", + "version": "abalone", + } + path = SessionsClient.version_path(**expected) + + # Check that the path construction is reversible. + actual = SessionsClient.parse_version_path(path) + assert expected == actual + + +def test_webhook_path(): + project = "squid" + location = "clam" + agent = "whelk" + webhook = "octopus" expected = "projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}".format( project=project, location=location, agent=agent, webhook=webhook, ) @@ -1628,10 +1656,10 @@ def test_webhook_path(): def test_parse_webhook_path(): expected = { - "project": "cuttlefish", - "location": "mussel", - "agent": "winkle", - "webhook": "nautilus", + "project": "oyster", + "location": "nudibranch", + "agent": "cuttlefish", + "webhook": "mussel", } path = SessionsClient.webhook_path(**expected) @@ -1641,7 +1669,7 @@ def test_parse_webhook_path(): def test_common_billing_account_path(): - billing_account = "scallop" + billing_account = "winkle" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1651,7 +1679,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "abalone", + "billing_account": "nautilus", } path = SessionsClient.common_billing_account_path(**expected) @@ -1661,7 +1689,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "squid" + folder = "scallop" expected = "folders/{folder}".format(folder=folder,) actual = SessionsClient.common_folder_path(folder) assert expected == actual @@ -1669,7 +1697,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "clam", + "folder": "abalone", } path = SessionsClient.common_folder_path(**expected) @@ -1679,7 +1707,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "whelk" + organization = "squid" expected = "organizations/{organization}".format(organization=organization,) actual = SessionsClient.common_organization_path(organization) assert expected == actual @@ -1687,7 +1715,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "octopus", + "organization": "clam", } path = SessionsClient.common_organization_path(**expected) @@ -1697,7 +1725,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "oyster" + project = "whelk" expected = "projects/{project}".format(project=project,) actual = SessionsClient.common_project_path(project) assert expected == actual @@ -1705,7 +1733,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nudibranch", + "project": "octopus", } path = SessionsClient.common_project_path(**expected) @@ -1715,8 +1743,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "cuttlefish" - location = "mussel" + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -1726,8 +1754,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "winkle", - "location": "nautilus", + "project": "cuttlefish", + "location": "mussel", } path = SessionsClient.common_location_path(**expected)