Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Commit 6296673

Browse files
feat(v2): added support to configure security settings, language code and time zone on conversation profile (#431)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 407663596 Source-Link: googleapis/googleapis@f9acb37 Source-Link: https://github.com/googleapis/googleapis-gen/commit/aa54a757068f005ab21064fb208a5ec597e49a9a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWE1NGE3NTcwNjhmMDA1YWIyMTA2NGZiMjA4YTVlYzU5N2U0OWE5YSJ9
1 parent fd06e9f commit 6296673

4 files changed

Lines changed: 126 additions & 34 deletions

File tree

google/cloud/dialogflow_v2/services/conversation_profiles/async_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ class ConversationProfilesAsyncClient:
6565
parse_conversation_profile_path = staticmethod(
6666
ConversationProfilesClient.parse_conversation_profile_path
6767
)
68+
cx_security_settings_path = staticmethod(
69+
ConversationProfilesClient.cx_security_settings_path
70+
)
71+
parse_cx_security_settings_path = staticmethod(
72+
ConversationProfilesClient.parse_cx_security_settings_path
73+
)
6874
document_path = staticmethod(ConversationProfilesClient.document_path)
6975
parse_document_path = staticmethod(ConversationProfilesClient.parse_document_path)
7076
knowledge_base_path = staticmethod(ConversationProfilesClient.knowledge_base_path)

google/cloud/dialogflow_v2/services/conversation_profiles/client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ def parse_conversation_profile_path(path: str) -> Dict[str, str]:
212212
)
213213
return m.groupdict() if m else {}
214214

215+
@staticmethod
216+
def cx_security_settings_path(
217+
project: str, location: str, security_settings: str,
218+
) -> str:
219+
"""Returns a fully-qualified cx_security_settings string."""
220+
return "projects/{project}/locations/{location}/securitySettings/{security_settings}".format(
221+
project=project, location=location, security_settings=security_settings,
222+
)
223+
224+
@staticmethod
225+
def parse_cx_security_settings_path(path: str) -> Dict[str, str]:
226+
"""Parses a cx_security_settings path into its component segments."""
227+
m = re.match(
228+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/securitySettings/(?P<security_settings>.+?)$",
229+
path,
230+
)
231+
return m.groupdict() if m else {}
232+
215233
@staticmethod
216234
def document_path(project: str, knowledge_base: str, document: str,) -> str:
217235
"""Returns a fully-qualified document string."""

google/cloud/dialogflow_v2/types/conversation_profile.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,21 @@ class ConversationProfile(proto.Message):
8080
stt_config (google.cloud.dialogflow_v2.types.SpeechToTextConfig):
8181
Settings for speech transcription.
8282
language_code (str):
83-
Language which represents the
84-
conversationProfile. If unspecified, the default
85-
language code en-us applies. Users need to
86-
create a ConversationProfile for each language
87-
they want to support.
83+
Language code for the conversation profile. If not
84+
specified, the language is en-US. Language at
85+
ConversationProfile should be set for all non en-US
86+
languages. This should be a
87+
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
88+
language tag. Example: "en-US".
89+
time_zone (str):
90+
The time zone of this conversational profile from the `time
91+
zone database <https://www.iana.org/time-zones>`__, e.g.,
92+
America/New_York, Europe/Paris. Defaults to
93+
America/New_York.
94+
security_settings (str):
95+
Name of the CX SecuritySettings reference for the agent.
96+
Format:
97+
``projects/<Project ID>/locations/<Location ID>/securitySettings/<Security Settings ID>``.
8898
"""
8999

90100
name = proto.Field(proto.STRING, number=1,)
@@ -115,6 +125,8 @@ class ConversationProfile(proto.Message):
115125
proto.MESSAGE, number=9, message=audio_config.SpeechToTextConfig,
116126
)
117127
language_code = proto.Field(proto.STRING, number=10,)
128+
time_zone = proto.Field(proto.STRING, number=14,)
129+
security_settings = proto.Field(proto.STRING, number=13,)
118130

119131

120132
class ListConversationProfilesRequest(proto.Message):
@@ -245,12 +257,17 @@ class AutomatedAgentConfig(proto.Message):
245257
``service-<Conversation Project Number>@gcp-sa-dialogflow.iam.gserviceaccount.com``
246258
the ``Dialogflow API Service Agent`` role in this project.
247259
248-
Format:
249-
``projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID or '-'>``.
250-
If environment is not specified, the default ``draft``
251-
environment is used. Refer to
252-
`DetectIntentRequest </dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest>`__
253-
for more details.
260+
- For ES agents, use format:
261+
``projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID or '-'>``.
262+
If environment is not specified, the default ``draft``
263+
environment is used. Refer to
264+
`DetectIntentRequest </dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest>`__
265+
for more details.
266+
267+
- For CX agents, use format
268+
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment ID or '-'>``.
269+
If environment is not specified, the default ``draft``
270+
environment is used.
254271
"""
255272

256273
agent = proto.Field(proto.STRING, number=1,)
@@ -409,7 +426,8 @@ class SuggestionQueryConfig(proto.Message):
409426
If this field is not set, it defaults to 0.0, which means
410427
that all suggestions are returned.
411428
412-
Supported features: ARTICLE_SUGGESTION.
429+
Supported features: ARTICLE_SUGGESTION, FAQ, SMART_REPLY,
430+
SMART_COMPOSE.
413431
context_filter_settings (google.cloud.dialogflow_v2.types.HumanAgentAssistantConfig.SuggestionQueryConfig.ContextFilterSettings):
414432
Determines how recent conversation context is
415433
filtered when generating suggestions. If

tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ def test_get_conversation_profile(
943943
name="name_value",
944944
display_name="display_name_value",
945945
language_code="language_code_value",
946+
time_zone="time_zone_value",
947+
security_settings="security_settings_value",
946948
)
947949
response = client.get_conversation_profile(request)
948950

@@ -956,6 +958,8 @@ def test_get_conversation_profile(
956958
assert response.name == "name_value"
957959
assert response.display_name == "display_name_value"
958960
assert response.language_code == "language_code_value"
961+
assert response.time_zone == "time_zone_value"
962+
assert response.security_settings == "security_settings_value"
959963

960964

961965
def test_get_conversation_profile_from_dict():
@@ -1002,6 +1006,8 @@ async def test_get_conversation_profile_async(
10021006
name="name_value",
10031007
display_name="display_name_value",
10041008
language_code="language_code_value",
1009+
time_zone="time_zone_value",
1010+
security_settings="security_settings_value",
10051011
)
10061012
)
10071013
response = await client.get_conversation_profile(request)
@@ -1016,6 +1022,8 @@ async def test_get_conversation_profile_async(
10161022
assert response.name == "name_value"
10171023
assert response.display_name == "display_name_value"
10181024
assert response.language_code == "language_code_value"
1025+
assert response.time_zone == "time_zone_value"
1026+
assert response.security_settings == "security_settings_value"
10191027

10201028

10211029
@pytest.mark.asyncio
@@ -1179,6 +1187,8 @@ def test_create_conversation_profile(
11791187
name="name_value",
11801188
display_name="display_name_value",
11811189
language_code="language_code_value",
1190+
time_zone="time_zone_value",
1191+
security_settings="security_settings_value",
11821192
)
11831193
response = client.create_conversation_profile(request)
11841194

@@ -1192,6 +1202,8 @@ def test_create_conversation_profile(
11921202
assert response.name == "name_value"
11931203
assert response.display_name == "display_name_value"
11941204
assert response.language_code == "language_code_value"
1205+
assert response.time_zone == "time_zone_value"
1206+
assert response.security_settings == "security_settings_value"
11951207

11961208

11971209
def test_create_conversation_profile_from_dict():
@@ -1238,6 +1250,8 @@ async def test_create_conversation_profile_async(
12381250
name="name_value",
12391251
display_name="display_name_value",
12401252
language_code="language_code_value",
1253+
time_zone="time_zone_value",
1254+
security_settings="security_settings_value",
12411255
)
12421256
)
12431257
response = await client.create_conversation_profile(request)
@@ -1252,6 +1266,8 @@ async def test_create_conversation_profile_async(
12521266
assert response.name == "name_value"
12531267
assert response.display_name == "display_name_value"
12541268
assert response.language_code == "language_code_value"
1269+
assert response.time_zone == "time_zone_value"
1270+
assert response.security_settings == "security_settings_value"
12551271

12561272

12571273
@pytest.mark.asyncio
@@ -1443,6 +1459,8 @@ def test_update_conversation_profile(
14431459
name="name_value",
14441460
display_name="display_name_value",
14451461
language_code="language_code_value",
1462+
time_zone="time_zone_value",
1463+
security_settings="security_settings_value",
14461464
)
14471465
response = client.update_conversation_profile(request)
14481466

@@ -1456,6 +1474,8 @@ def test_update_conversation_profile(
14561474
assert response.name == "name_value"
14571475
assert response.display_name == "display_name_value"
14581476
assert response.language_code == "language_code_value"
1477+
assert response.time_zone == "time_zone_value"
1478+
assert response.security_settings == "security_settings_value"
14591479

14601480

14611481
def test_update_conversation_profile_from_dict():
@@ -1502,6 +1522,8 @@ async def test_update_conversation_profile_async(
15021522
name="name_value",
15031523
display_name="display_name_value",
15041524
language_code="language_code_value",
1525+
time_zone="time_zone_value",
1526+
security_settings="security_settings_value",
15051527
)
15061528
)
15071529
response = await client.update_conversation_profile(request)
@@ -1516,6 +1538,8 @@ async def test_update_conversation_profile_async(
15161538
assert response.name == "name_value"
15171539
assert response.display_name == "display_name_value"
15181540
assert response.language_code == "language_code_value"
1541+
assert response.time_zone == "time_zone_value"
1542+
assert response.security_settings == "security_settings_value"
15191543

15201544

15211545
@pytest.mark.asyncio
@@ -2390,10 +2414,36 @@ def test_parse_conversation_profile_path():
23902414
assert expected == actual
23912415

23922416

2393-
def test_document_path():
2417+
def test_cx_security_settings_path():
23942418
project = "squid"
2395-
knowledge_base = "clam"
2396-
document = "whelk"
2419+
location = "clam"
2420+
security_settings = "whelk"
2421+
expected = "projects/{project}/locations/{location}/securitySettings/{security_settings}".format(
2422+
project=project, location=location, security_settings=security_settings,
2423+
)
2424+
actual = ConversationProfilesClient.cx_security_settings_path(
2425+
project, location, security_settings
2426+
)
2427+
assert expected == actual
2428+
2429+
2430+
def test_parse_cx_security_settings_path():
2431+
expected = {
2432+
"project": "octopus",
2433+
"location": "oyster",
2434+
"security_settings": "nudibranch",
2435+
}
2436+
path = ConversationProfilesClient.cx_security_settings_path(**expected)
2437+
2438+
# Check that the path construction is reversible.
2439+
actual = ConversationProfilesClient.parse_cx_security_settings_path(path)
2440+
assert expected == actual
2441+
2442+
2443+
def test_document_path():
2444+
project = "cuttlefish"
2445+
knowledge_base = "mussel"
2446+
document = "winkle"
23972447
expected = "projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}".format(
23982448
project=project, knowledge_base=knowledge_base, document=document,
23992449
)
@@ -2403,9 +2453,9 @@ def test_document_path():
24032453

24042454
def test_parse_document_path():
24052455
expected = {
2406-
"project": "octopus",
2407-
"knowledge_base": "oyster",
2408-
"document": "nudibranch",
2456+
"project": "nautilus",
2457+
"knowledge_base": "scallop",
2458+
"document": "abalone",
24092459
}
24102460
path = ConversationProfilesClient.document_path(**expected)
24112461

@@ -2415,8 +2465,8 @@ def test_parse_document_path():
24152465

24162466

24172467
def test_knowledge_base_path():
2418-
project = "cuttlefish"
2419-
knowledge_base = "mussel"
2468+
project = "squid"
2469+
knowledge_base = "clam"
24202470
expected = "projects/{project}/knowledgeBases/{knowledge_base}".format(
24212471
project=project, knowledge_base=knowledge_base,
24222472
)
@@ -2426,8 +2476,8 @@ def test_knowledge_base_path():
24262476

24272477
def test_parse_knowledge_base_path():
24282478
expected = {
2429-
"project": "winkle",
2430-
"knowledge_base": "nautilus",
2479+
"project": "whelk",
2480+
"knowledge_base": "octopus",
24312481
}
24322482
path = ConversationProfilesClient.knowledge_base_path(**expected)
24332483

@@ -2437,7 +2487,7 @@ def test_parse_knowledge_base_path():
24372487

24382488

24392489
def test_common_billing_account_path():
2440-
billing_account = "scallop"
2490+
billing_account = "oyster"
24412491
expected = "billingAccounts/{billing_account}".format(
24422492
billing_account=billing_account,
24432493
)
@@ -2447,7 +2497,7 @@ def test_common_billing_account_path():
24472497

24482498
def test_parse_common_billing_account_path():
24492499
expected = {
2450-
"billing_account": "abalone",
2500+
"billing_account": "nudibranch",
24512501
}
24522502
path = ConversationProfilesClient.common_billing_account_path(**expected)
24532503

@@ -2457,15 +2507,15 @@ def test_parse_common_billing_account_path():
24572507

24582508

24592509
def test_common_folder_path():
2460-
folder = "squid"
2510+
folder = "cuttlefish"
24612511
expected = "folders/{folder}".format(folder=folder,)
24622512
actual = ConversationProfilesClient.common_folder_path(folder)
24632513
assert expected == actual
24642514

24652515

24662516
def test_parse_common_folder_path():
24672517
expected = {
2468-
"folder": "clam",
2518+
"folder": "mussel",
24692519
}
24702520
path = ConversationProfilesClient.common_folder_path(**expected)
24712521

@@ -2475,15 +2525,15 @@ def test_parse_common_folder_path():
24752525

24762526

24772527
def test_common_organization_path():
2478-
organization = "whelk"
2528+
organization = "winkle"
24792529
expected = "organizations/{organization}".format(organization=organization,)
24802530
actual = ConversationProfilesClient.common_organization_path(organization)
24812531
assert expected == actual
24822532

24832533

24842534
def test_parse_common_organization_path():
24852535
expected = {
2486-
"organization": "octopus",
2536+
"organization": "nautilus",
24872537
}
24882538
path = ConversationProfilesClient.common_organization_path(**expected)
24892539

@@ -2493,15 +2543,15 @@ def test_parse_common_organization_path():
24932543

24942544

24952545
def test_common_project_path():
2496-
project = "oyster"
2546+
project = "scallop"
24972547
expected = "projects/{project}".format(project=project,)
24982548
actual = ConversationProfilesClient.common_project_path(project)
24992549
assert expected == actual
25002550

25012551

25022552
def test_parse_common_project_path():
25032553
expected = {
2504-
"project": "nudibranch",
2554+
"project": "abalone",
25052555
}
25062556
path = ConversationProfilesClient.common_project_path(**expected)
25072557

@@ -2511,8 +2561,8 @@ def test_parse_common_project_path():
25112561

25122562

25132563
def test_common_location_path():
2514-
project = "cuttlefish"
2515-
location = "mussel"
2564+
project = "squid"
2565+
location = "clam"
25162566
expected = "projects/{project}/locations/{location}".format(
25172567
project=project, location=location,
25182568
)
@@ -2522,8 +2572,8 @@ def test_common_location_path():
25222572

25232573
def test_parse_common_location_path():
25242574
expected = {
2525-
"project": "winkle",
2526-
"location": "nautilus",
2575+
"project": "whelk",
2576+
"location": "octopus",
25272577
}
25282578
path = ConversationProfilesClient.common_location_path(**expected)
25292579

0 commit comments

Comments
 (0)