Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 24ef477

Browse files
feat(v3): add advanced settings for agent level (#137)
PiperOrigin-RevId: 387850898 Source-Link: googleapis/googleapis@05d477b 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
1 parent b370746 commit 24ef477

File tree

15 files changed

+306
-25
lines changed

15 files changed

+306
-25
lines changed

google/cloud/dialogflowcx/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
WebhooksAsyncClient,
7272
)
7373

74+
from google.cloud.dialogflowcx_v3.types.advanced_settings import AdvancedSettings
7475
from google.cloud.dialogflowcx_v3.types.agent import Agent
7576
from google.cloud.dialogflowcx_v3.types.agent import AgentValidationResult
7677
from google.cloud.dialogflowcx_v3.types.agent import CreateAgentRequest
@@ -130,6 +131,8 @@
130131
from google.cloud.dialogflowcx_v3.types.experiment import GetExperimentRequest
131132
from google.cloud.dialogflowcx_v3.types.experiment import ListExperimentsRequest
132133
from google.cloud.dialogflowcx_v3.types.experiment import ListExperimentsResponse
134+
from google.cloud.dialogflowcx_v3.types.experiment import RolloutConfig
135+
from google.cloud.dialogflowcx_v3.types.experiment import RolloutState
133136
from google.cloud.dialogflowcx_v3.types.experiment import StartExperimentRequest
134137
from google.cloud.dialogflowcx_v3.types.experiment import StopExperimentRequest
135138
from google.cloud.dialogflowcx_v3.types.experiment import UpdateExperimentRequest
@@ -335,6 +338,7 @@
335338
"VersionsAsyncClient",
336339
"WebhooksClient",
337340
"WebhooksAsyncClient",
341+
"AdvancedSettings",
338342
"Agent",
339343
"AgentValidationResult",
340344
"CreateAgentRequest",
@@ -386,6 +390,8 @@
386390
"GetExperimentRequest",
387391
"ListExperimentsRequest",
388392
"ListExperimentsResponse",
393+
"RolloutConfig",
394+
"RolloutState",
389395
"StartExperimentRequest",
390396
"StopExperimentRequest",
391397
"UpdateExperimentRequest",

google/cloud/dialogflowcx_v3/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from .services.webhooks import WebhooksClient
4444
from .services.webhooks import WebhooksAsyncClient
4545

46+
from .types.advanced_settings import AdvancedSettings
4647
from .types.agent import Agent
4748
from .types.agent import AgentValidationResult
4849
from .types.agent import CreateAgentRequest
@@ -94,6 +95,8 @@
9495
from .types.experiment import GetExperimentRequest
9596
from .types.experiment import ListExperimentsRequest
9697
from .types.experiment import ListExperimentsResponse
98+
from .types.experiment import RolloutConfig
99+
from .types.experiment import RolloutState
97100
from .types.experiment import StartExperimentRequest
98101
from .types.experiment import StopExperimentRequest
99102
from .types.experiment import UpdateExperimentRequest
@@ -247,6 +250,7 @@
247250
"TransitionRouteGroupsAsyncClient",
248251
"VersionsAsyncClient",
249252
"WebhooksAsyncClient",
253+
"AdvancedSettings",
250254
"Agent",
251255
"AgentValidationResult",
252256
"AgentsClient",
@@ -386,6 +390,8 @@
386390
"ResourceName",
387391
"ResponseMessage",
388392
"RestoreAgentRequest",
393+
"RolloutConfig",
394+
"RolloutState",
389395
"RunContinuousTestMetadata",
390396
"RunContinuousTestRequest",
391397
"RunContinuousTestResponse",

google/cloud/dialogflowcx_v3/services/agents/async_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from google.api_core import operation # type: ignore
3030
from google.api_core import operation_async # type: ignore
3131
from google.cloud.dialogflowcx_v3.services.agents import pagers
32+
from google.cloud.dialogflowcx_v3.types import advanced_settings
3233
from google.cloud.dialogflowcx_v3.types import agent
3334
from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
3435
from google.cloud.dialogflowcx_v3.types import flow

google/cloud/dialogflowcx_v3/services/agents/client.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from google.api_core import operation # type: ignore
3434
from google.api_core import operation_async # type: ignore
3535
from google.cloud.dialogflowcx_v3.services.agents import pagers
36+
from google.cloud.dialogflowcx_v3.types import advanced_settings
3637
from google.cloud.dialogflowcx_v3.types import agent
3738
from google.cloud.dialogflowcx_v3.types import agent as gcdc_agent
3839
from google.cloud.dialogflowcx_v3.types import flow

google/cloud/dialogflowcx_v3/services/sessions/async_client.py

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class SessionsAsyncClient:
7575
parse_transition_route_group_path = staticmethod(
7676
SessionsClient.parse_transition_route_group_path
7777
)
78+
version_path = staticmethod(SessionsClient.version_path)
79+
parse_version_path = staticmethod(SessionsClient.parse_version_path)
7880
webhook_path = staticmethod(SessionsClient.webhook_path)
7981
parse_webhook_path = staticmethod(SessionsClient.parse_webhook_path)
8082
common_billing_account_path = staticmethod(

google/cloud/dialogflowcx_v3/services/sessions/client.py

+18
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,24 @@ def parse_transition_route_group_path(path: str) -> Dict[str, str]:
296296
)
297297
return m.groupdict() if m else {}
298298

299+
@staticmethod
300+
def version_path(
301+
project: str, location: str, agent: str, flow: str, version: str,
302+
) -> str:
303+
"""Returns a fully-qualified version string."""
304+
return "projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/versions/{version}".format(
305+
project=project, location=location, agent=agent, flow=flow, version=version,
306+
)
307+
308+
@staticmethod
309+
def parse_version_path(path: str) -> Dict[str, str]:
310+
"""Parses a version path into its component segments."""
311+
m = re.match(
312+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/agents/(?P<agent>.+?)/flows/(?P<flow>.+?)/versions/(?P<version>.+?)$",
313+
path,
314+
)
315+
return m.groupdict() if m else {}
316+
299317
@staticmethod
300318
def webhook_path(project: str, location: str, agent: str, webhook: str,) -> str:
301319
"""Returns a fully-qualified webhook string."""

google/cloud/dialogflowcx_v3/types/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from .advanced_settings import AdvancedSettings
1617
from .agent import (
1718
Agent,
1819
AgentValidationResult,
@@ -73,6 +74,8 @@
7374
GetExperimentRequest,
7475
ListExperimentsRequest,
7576
ListExperimentsResponse,
77+
RolloutConfig,
78+
RolloutState,
7679
StartExperimentRequest,
7780
StopExperimentRequest,
7881
UpdateExperimentRequest,
@@ -235,6 +238,7 @@
235238
)
236239

237240
__all__ = (
241+
"AdvancedSettings",
238242
"Agent",
239243
"AgentValidationResult",
240244
"CreateAgentRequest",
@@ -286,6 +290,8 @@
286290
"GetExperimentRequest",
287291
"ListExperimentsRequest",
288292
"ListExperimentsResponse",
293+
"RolloutConfig",
294+
"RolloutState",
289295
"StartExperimentRequest",
290296
"StopExperimentRequest",
291297
"UpdateExperimentRequest",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
import proto # type: ignore
17+
18+
19+
__protobuf__ = proto.module(
20+
package="google.cloud.dialogflow.cx.v3", manifest={"AdvancedSettings",},
21+
)
22+
23+
24+
class AdvancedSettings(proto.Message):
25+
r"""Hierarchical advanced settings for
26+
agent/flow/page/fulfillment/parameter. Settings exposed at lower
27+
level overrides the settings exposed at higher level.
28+
29+
Hierarchy: Agent->Flow->Page->Fulfillment/Parameter.
30+
31+
Attributes:
32+
logging_settings (google.cloud.dialogflowcx_v3.types.AdvancedSettings.LoggingSettings):
33+
Settings for logging.
34+
Settings for Dialogflow History, Contact Center
35+
messages, StackDriver logs, and speech logging.
36+
Exposed at the following levels:
37+
- Agent level.
38+
"""
39+
40+
class LoggingSettings(proto.Message):
41+
r"""Define behaviors on logging.
42+
Attributes:
43+
enable_stackdriver_logging (bool):
44+
If true, StackDriver logging is currently
45+
enabled.
46+
enable_interaction_logging (bool):
47+
If true, DF Interaction logging is currently
48+
enabled.
49+
"""
50+
51+
enable_stackdriver_logging = proto.Field(proto.BOOL, number=2,)
52+
enable_interaction_logging = proto.Field(proto.BOOL, number=3,)
53+
54+
logging_settings = proto.Field(proto.MESSAGE, number=6, message=LoggingSettings,)
55+
56+
57+
__all__ = tuple(sorted(__protobuf__.manifest))

google/cloud/dialogflowcx_v3/types/agent.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#
1616
import proto # type: ignore
1717

18+
from google.cloud.dialogflowcx_v3.types import (
19+
advanced_settings as gcdc_advanced_settings,
20+
)
1821
from google.cloud.dialogflowcx_v3.types import flow
1922
from google.protobuf import field_mask_pb2 # type: ignore
2023

@@ -114,11 +117,18 @@ class Agent(proto.Message):
114117
reference for the agent. Format:
115118
``projects/<Project ID>/locations/<Location ID>/securitySettings/<Security Settings ID>``.
116119
enable_stackdriver_logging (bool):
117-
Indicates if stackdriver logging is enabled
118-
for the agent.
120+
Indicates if stackdriver logging is enabled for the agent.
121+
Please use
122+
[agent.advanced_settings][google.cloud.dialogflow.cx.v3.AdvancedSettings.LoggingSettings]
123+
instead.
119124
enable_spell_correction (bool):
120125
Indicates if automatic spell correction is
121126
enabled in detect intent requests.
127+
advanced_settings (google.cloud.dialogflowcx_v3.types.AdvancedSettings):
128+
Hierarchical advanced settings for this
129+
agent. The settings exposed at the lower level
130+
overrides the settings exposed at the higher
131+
level.
122132
"""
123133

124134
name = proto.Field(proto.STRING, number=1,)
@@ -135,6 +145,9 @@ class Agent(proto.Message):
135145
security_settings = proto.Field(proto.STRING, number=17,)
136146
enable_stackdriver_logging = proto.Field(proto.BOOL, number=18,)
137147
enable_spell_correction = proto.Field(proto.BOOL, number=20,)
148+
advanced_settings = proto.Field(
149+
proto.MESSAGE, number=22, message=gcdc_advanced_settings.AdvancedSettings,
150+
)
138151

139152

140153
class ListAgentsRequest(proto.Message):

google/cloud/dialogflowcx_v3/types/experiment.py

+89-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"Experiment",
2727
"VersionVariants",
2828
"VariantsHistory",
29+
"RolloutConfig",
30+
"RolloutState",
2931
"ListExperimentsRequest",
3032
"ListExperimentsResponse",
3133
"GetExperimentRequest",
@@ -57,12 +59,26 @@ class Experiment(proto.Message):
5759
state (google.cloud.dialogflowcx_v3.types.Experiment.State):
5860
The current state of the experiment.
5961
Transition triggered by
60-
Expriments.StartExperiment: PENDING->RUNNING.
62+
Experiments.StartExperiment: DRAFT->RUNNING.
6163
Transition triggered by
62-
Expriments.CancelExperiment: PENDING->CANCELLED
63-
or RUNNING->CANCELLED.
64+
Experiments.CancelExperiment: DRAFT->DONE or
65+
RUNNING->DONE.
6466
definition (google.cloud.dialogflowcx_v3.types.Experiment.Definition):
6567
The definition of the experiment.
68+
rollout_config (google.cloud.dialogflowcx_v3.types.RolloutConfig):
69+
The configuration for auto rollout. If set,
70+
there should be exactly two variants in the
71+
experiment (control variant being the default
72+
version of the flow), the traffic allocation for
73+
the non-control variant will gradually increase
74+
to 100% when conditions are met, and eventually
75+
replace the control variant to become the
76+
default version of the flow.
77+
rollout_state (google.cloud.dialogflowcx_v3.types.RolloutState):
78+
State of the auto rollout process.
79+
rollout_failure_reason (str):
80+
The reason why rollout has failed. Should only be set when
81+
state is ROLLOUT_FAILED.
6682
result (google.cloud.dialogflowcx_v3.types.Experiment.Result):
6783
Inference result of the experiment.
6884
create_time (google.protobuf.timestamp_pb2.Timestamp):
@@ -90,6 +106,7 @@ class State(proto.Enum):
90106
DRAFT = 1
91107
RUNNING = 2
92108
DONE = 3
109+
ROLLOUT_FAILED = 4
93110

94111
class Definition(proto.Message):
95112
r"""Definition of the experiment.
@@ -225,6 +242,9 @@ class VersionMetrics(proto.Message):
225242
description = proto.Field(proto.STRING, number=3,)
226243
state = proto.Field(proto.ENUM, number=4, enum=State,)
227244
definition = proto.Field(proto.MESSAGE, number=5, message=Definition,)
245+
rollout_config = proto.Field(proto.MESSAGE, number=14, message="RolloutConfig",)
246+
rollout_state = proto.Field(proto.MESSAGE, number=15, message="RolloutState",)
247+
rollout_failure_reason = proto.Field(proto.STRING, number=16,)
228248
result = proto.Field(proto.MESSAGE, number=6, message=Result,)
229249
create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,)
230250
start_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,)
@@ -283,6 +303,72 @@ class VariantsHistory(proto.Message):
283303
update_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
284304

285305

306+
class RolloutConfig(proto.Message):
307+
r"""The configuration for auto rollout.
308+
Attributes:
309+
rollout_steps (Sequence[google.cloud.dialogflowcx_v3.types.RolloutConfig.RolloutStep]):
310+
Steps to roll out a flow version. Steps
311+
should be sorted by percentage in ascending
312+
order.
313+
rollout_condition (str):
314+
The conditions that are used to evaluate the success of a
315+
rollout step. If not specified, all rollout steps will
316+
proceed to the next one unless failure conditions are met.
317+
E.g. "containment_rate > 60% AND callback_rate < 20%". See
318+
the `conditions
319+
reference <https://cloud.google.com/dialogflow/cx/docs/reference/condition>`__.
320+
failure_condition (str):
321+
The conditions that are used to evaluate the failure of a
322+
rollout step. If not specified, no rollout steps will fail.
323+
E.g. "containment_rate < 10% OR average_turn_count < 3". See
324+
the `conditions
325+
reference <https://cloud.google.com/dialogflow/cx/docs/reference/condition>`__.
326+
"""
327+
328+
class RolloutStep(proto.Message):
329+
r"""A single rollout step with specified traffic allocation.
330+
Attributes:
331+
display_name (str):
332+
The name of the rollout step;
333+
traffic_percent (int):
334+
The percentage of traffic allocated to the flow version of
335+
this rollout step. (0%, 100%].
336+
min_duration (google.protobuf.duration_pb2.Duration):
337+
The minimum time that this step should last.
338+
Should be longer than 1 hour. If not set, the
339+
default minimum duration for each step will be 1
340+
hour.
341+
"""
342+
343+
display_name = proto.Field(proto.STRING, number=1,)
344+
traffic_percent = proto.Field(proto.INT32, number=2,)
345+
min_duration = proto.Field(
346+
proto.MESSAGE, number=3, message=duration_pb2.Duration,
347+
)
348+
349+
rollout_steps = proto.RepeatedField(proto.MESSAGE, number=1, message=RolloutStep,)
350+
rollout_condition = proto.Field(proto.STRING, number=2,)
351+
failure_condition = proto.Field(proto.STRING, number=3,)
352+
353+
354+
class RolloutState(proto.Message):
355+
r"""State of the auto-rollout process.
356+
Attributes:
357+
step (str):
358+
Display name of the current auto rollout
359+
step.
360+
step_index (int):
361+
Index of the current step in the auto rollout
362+
steps list.
363+
start_time (google.protobuf.timestamp_pb2.Timestamp):
364+
Start time of the current step.
365+
"""
366+
367+
step = proto.Field(proto.STRING, number=1,)
368+
step_index = proto.Field(proto.INT32, number=3,)
369+
start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
370+
371+
286372
class ListExperimentsRequest(proto.Message):
287373
r"""The request message for
288374
[Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments].

0 commit comments

Comments
 (0)