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

Commit

Permalink
feat(v2): added support to configure security settings, language code…
Browse files Browse the repository at this point in the history
… and time zone on conversation profile (#431)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 407663596

Source-Link: googleapis/googleapis@f9acb37

Source-Link: googleapis/googleapis-gen@aa54a75
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWE1NGE3NTcwNjhmMDA1YWIyMTA2NGZiMjA4YTVlYzU5N2U0OWE5YSJ9
  • Loading branch information
gcf-owl-bot[bot] committed Nov 5, 2021
1 parent fd06e9f commit 6296673
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 34 deletions.
Expand Up @@ -65,6 +65,12 @@ class ConversationProfilesAsyncClient:
parse_conversation_profile_path = staticmethod(
ConversationProfilesClient.parse_conversation_profile_path
)
cx_security_settings_path = staticmethod(
ConversationProfilesClient.cx_security_settings_path
)
parse_cx_security_settings_path = staticmethod(
ConversationProfilesClient.parse_cx_security_settings_path
)
document_path = staticmethod(ConversationProfilesClient.document_path)
parse_document_path = staticmethod(ConversationProfilesClient.parse_document_path)
knowledge_base_path = staticmethod(ConversationProfilesClient.knowledge_base_path)
Expand Down
Expand Up @@ -212,6 +212,24 @@ def parse_conversation_profile_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

@staticmethod
def cx_security_settings_path(
project: str, location: str, security_settings: str,
) -> str:
"""Returns a fully-qualified cx_security_settings string."""
return "projects/{project}/locations/{location}/securitySettings/{security_settings}".format(
project=project, location=location, security_settings=security_settings,
)

@staticmethod
def parse_cx_security_settings_path(path: str) -> Dict[str, str]:
"""Parses a cx_security_settings path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/securitySettings/(?P<security_settings>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def document_path(project: str, knowledge_base: str, document: str,) -> str:
"""Returns a fully-qualified document string."""
Expand Down
42 changes: 30 additions & 12 deletions google/cloud/dialogflow_v2/types/conversation_profile.py
Expand Up @@ -80,11 +80,21 @@ class ConversationProfile(proto.Message):
stt_config (google.cloud.dialogflow_v2.types.SpeechToTextConfig):
Settings for speech transcription.
language_code (str):
Language which represents the
conversationProfile. If unspecified, the default
language code en-us applies. Users need to
create a ConversationProfile for each language
they want to support.
Language code for the conversation profile. If not
specified, the language is en-US. Language at
ConversationProfile should be set for all non en-US
languages. This should be a
`BCP-47 <https://www.rfc-editor.org/rfc/bcp/bcp47.txt>`__
language tag. Example: "en-US".
time_zone (str):
The time zone of this conversational profile from the `time
zone database <https://www.iana.org/time-zones>`__, e.g.,
America/New_York, Europe/Paris. Defaults to
America/New_York.
security_settings (str):
Name of the CX SecuritySettings reference for the agent.
Format:
``projects/<Project ID>/locations/<Location ID>/securitySettings/<Security Settings ID>``.
"""

name = proto.Field(proto.STRING, number=1,)
Expand Down Expand Up @@ -115,6 +125,8 @@ class ConversationProfile(proto.Message):
proto.MESSAGE, number=9, message=audio_config.SpeechToTextConfig,
)
language_code = proto.Field(proto.STRING, number=10,)
time_zone = proto.Field(proto.STRING, number=14,)
security_settings = proto.Field(proto.STRING, number=13,)


class ListConversationProfilesRequest(proto.Message):
Expand Down Expand Up @@ -245,12 +257,17 @@ class AutomatedAgentConfig(proto.Message):
``service-<Conversation Project Number>@gcp-sa-dialogflow.iam.gserviceaccount.com``
the ``Dialogflow API Service Agent`` role in this project.
Format:
``projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID or '-'>``.
If environment is not specified, the default ``draft``
environment is used. Refer to
`DetectIntentRequest </dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest>`__
for more details.
- For ES agents, use format:
``projects/<Project ID>/locations/<Location ID>/agent/environments/<Environment ID or '-'>``.
If environment is not specified, the default ``draft``
environment is used. Refer to
`DetectIntentRequest </dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2#google.cloud.dialogflow.v2.DetectIntentRequest>`__
for more details.
- For CX agents, use format
``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment ID or '-'>``.
If environment is not specified, the default ``draft``
environment is used.
"""

agent = proto.Field(proto.STRING, number=1,)
Expand Down Expand Up @@ -409,7 +426,8 @@ class SuggestionQueryConfig(proto.Message):
If this field is not set, it defaults to 0.0, which means
that all suggestions are returned.
Supported features: ARTICLE_SUGGESTION.
Supported features: ARTICLE_SUGGESTION, FAQ, SMART_REPLY,
SMART_COMPOSE.
context_filter_settings (google.cloud.dialogflow_v2.types.HumanAgentAssistantConfig.SuggestionQueryConfig.ContextFilterSettings):
Determines how recent conversation context is
filtered when generating suggestions. If
Expand Down
94 changes: 72 additions & 22 deletions tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py
Expand Up @@ -943,6 +943,8 @@ def test_get_conversation_profile(
name="name_value",
display_name="display_name_value",
language_code="language_code_value",
time_zone="time_zone_value",
security_settings="security_settings_value",
)
response = client.get_conversation_profile(request)

Expand All @@ -956,6 +958,8 @@ def test_get_conversation_profile(
assert response.name == "name_value"
assert response.display_name == "display_name_value"
assert response.language_code == "language_code_value"
assert response.time_zone == "time_zone_value"
assert response.security_settings == "security_settings_value"


def test_get_conversation_profile_from_dict():
Expand Down Expand Up @@ -1002,6 +1006,8 @@ async def test_get_conversation_profile_async(
name="name_value",
display_name="display_name_value",
language_code="language_code_value",
time_zone="time_zone_value",
security_settings="security_settings_value",
)
)
response = await client.get_conversation_profile(request)
Expand All @@ -1016,6 +1022,8 @@ async def test_get_conversation_profile_async(
assert response.name == "name_value"
assert response.display_name == "display_name_value"
assert response.language_code == "language_code_value"
assert response.time_zone == "time_zone_value"
assert response.security_settings == "security_settings_value"


@pytest.mark.asyncio
Expand Down Expand Up @@ -1179,6 +1187,8 @@ def test_create_conversation_profile(
name="name_value",
display_name="display_name_value",
language_code="language_code_value",
time_zone="time_zone_value",
security_settings="security_settings_value",
)
response = client.create_conversation_profile(request)

Expand All @@ -1192,6 +1202,8 @@ def test_create_conversation_profile(
assert response.name == "name_value"
assert response.display_name == "display_name_value"
assert response.language_code == "language_code_value"
assert response.time_zone == "time_zone_value"
assert response.security_settings == "security_settings_value"


def test_create_conversation_profile_from_dict():
Expand Down Expand Up @@ -1238,6 +1250,8 @@ async def test_create_conversation_profile_async(
name="name_value",
display_name="display_name_value",
language_code="language_code_value",
time_zone="time_zone_value",
security_settings="security_settings_value",
)
)
response = await client.create_conversation_profile(request)
Expand All @@ -1252,6 +1266,8 @@ async def test_create_conversation_profile_async(
assert response.name == "name_value"
assert response.display_name == "display_name_value"
assert response.language_code == "language_code_value"
assert response.time_zone == "time_zone_value"
assert response.security_settings == "security_settings_value"


@pytest.mark.asyncio
Expand Down Expand Up @@ -1443,6 +1459,8 @@ def test_update_conversation_profile(
name="name_value",
display_name="display_name_value",
language_code="language_code_value",
time_zone="time_zone_value",
security_settings="security_settings_value",
)
response = client.update_conversation_profile(request)

Expand All @@ -1456,6 +1474,8 @@ def test_update_conversation_profile(
assert response.name == "name_value"
assert response.display_name == "display_name_value"
assert response.language_code == "language_code_value"
assert response.time_zone == "time_zone_value"
assert response.security_settings == "security_settings_value"


def test_update_conversation_profile_from_dict():
Expand Down Expand Up @@ -1502,6 +1522,8 @@ async def test_update_conversation_profile_async(
name="name_value",
display_name="display_name_value",
language_code="language_code_value",
time_zone="time_zone_value",
security_settings="security_settings_value",
)
)
response = await client.update_conversation_profile(request)
Expand All @@ -1516,6 +1538,8 @@ async def test_update_conversation_profile_async(
assert response.name == "name_value"
assert response.display_name == "display_name_value"
assert response.language_code == "language_code_value"
assert response.time_zone == "time_zone_value"
assert response.security_settings == "security_settings_value"


@pytest.mark.asyncio
Expand Down Expand Up @@ -2390,10 +2414,36 @@ def test_parse_conversation_profile_path():
assert expected == actual


def test_document_path():
def test_cx_security_settings_path():
project = "squid"
knowledge_base = "clam"
document = "whelk"
location = "clam"
security_settings = "whelk"
expected = "projects/{project}/locations/{location}/securitySettings/{security_settings}".format(
project=project, location=location, security_settings=security_settings,
)
actual = ConversationProfilesClient.cx_security_settings_path(
project, location, security_settings
)
assert expected == actual


def test_parse_cx_security_settings_path():
expected = {
"project": "octopus",
"location": "oyster",
"security_settings": "nudibranch",
}
path = ConversationProfilesClient.cx_security_settings_path(**expected)

# Check that the path construction is reversible.
actual = ConversationProfilesClient.parse_cx_security_settings_path(path)
assert expected == actual


def test_document_path():
project = "cuttlefish"
knowledge_base = "mussel"
document = "winkle"
expected = "projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}".format(
project=project, knowledge_base=knowledge_base, document=document,
)
Expand All @@ -2403,9 +2453,9 @@ def test_document_path():

def test_parse_document_path():
expected = {
"project": "octopus",
"knowledge_base": "oyster",
"document": "nudibranch",
"project": "nautilus",
"knowledge_base": "scallop",
"document": "abalone",
}
path = ConversationProfilesClient.document_path(**expected)

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


def test_knowledge_base_path():
project = "cuttlefish"
knowledge_base = "mussel"
project = "squid"
knowledge_base = "clam"
expected = "projects/{project}/knowledgeBases/{knowledge_base}".format(
project=project, knowledge_base=knowledge_base,
)
Expand All @@ -2426,8 +2476,8 @@ def test_knowledge_base_path():

def test_parse_knowledge_base_path():
expected = {
"project": "winkle",
"knowledge_base": "nautilus",
"project": "whelk",
"knowledge_base": "octopus",
}
path = ConversationProfilesClient.knowledge_base_path(**expected)

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


def test_common_billing_account_path():
billing_account = "scallop"
billing_account = "oyster"
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
Expand All @@ -2447,7 +2497,7 @@ def test_common_billing_account_path():

def test_parse_common_billing_account_path():
expected = {
"billing_account": "abalone",
"billing_account": "nudibranch",
}
path = ConversationProfilesClient.common_billing_account_path(**expected)

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


def test_common_folder_path():
folder = "squid"
folder = "cuttlefish"
expected = "folders/{folder}".format(folder=folder,)
actual = ConversationProfilesClient.common_folder_path(folder)
assert expected == actual


def test_parse_common_folder_path():
expected = {
"folder": "clam",
"folder": "mussel",
}
path = ConversationProfilesClient.common_folder_path(**expected)

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


def test_common_organization_path():
organization = "whelk"
organization = "winkle"
expected = "organizations/{organization}".format(organization=organization,)
actual = ConversationProfilesClient.common_organization_path(organization)
assert expected == actual


def test_parse_common_organization_path():
expected = {
"organization": "octopus",
"organization": "nautilus",
}
path = ConversationProfilesClient.common_organization_path(**expected)

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


def test_common_project_path():
project = "oyster"
project = "scallop"
expected = "projects/{project}".format(project=project,)
actual = ConversationProfilesClient.common_project_path(project)
assert expected == actual


def test_parse_common_project_path():
expected = {
"project": "nudibranch",
"project": "abalone",
}
path = ConversationProfilesClient.common_project_path(**expected)

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


def test_common_location_path():
project = "cuttlefish"
location = "mussel"
project = "squid"
location = "clam"
expected = "projects/{project}/locations/{location}".format(
project=project, location=location,
)
Expand All @@ -2522,8 +2572,8 @@ def test_common_location_path():

def test_parse_common_location_path():
expected = {
"project": "winkle",
"location": "nautilus",
"project": "whelk",
"location": "octopus",
}
path = ConversationProfilesClient.common_location_path(**expected)

Expand Down

0 comments on commit 6296673

Please sign in to comment.