From bfc25b7040243537663b1c5ece50a2d8f2d6d8c3 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:15:00 -0400 Subject: [PATCH] feat: add optional SpeechConfig to UploadConversationRequest (#11750) BEGIN_COMMIT_OVERRIDE feat: add optional SpeechConfig to UploadConversationRequest END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. PiperOrigin-RevId: 567616394 Source-Link: https://github.com/googleapis/googleapis/commit/37b45d1b5ebe4200fdc1250b85b3111e0f3c98c3 Source-Link: https://github.com/googleapis/googleapis-gen/commit/fa3a5648d3267a52ff8742c6bca465d306fcf4a5 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRhY3QtY2VudGVyLWluc2lnaHRzLy5Pd2xCb3QueWFtbCIsImgiOiJmYTNhNTY0OGQzMjY3YTUyZmY4NzQyYzZiY2E0NjVkMzA2ZmNmNGE1In0= --------- Co-authored-by: Owl Bot Co-authored-by: ohmayr --- .../CONTRIBUTING.rst | 4 +- .../cloud/contact_center_insights/__init__.py | 2 + .../contact_center_insights/gapic_version.py | 2 +- .../contact_center_insights_v1/__init__.py | 2 + .../gapic_version.py | 2 +- .../contact_center_insights/async_client.py | 4 ++ .../contact_center_insights/client.py | 24 +++++++ .../types/__init__.py | 2 + .../types/contact_center_insights.py | 13 +++- .../types/resources.py | 26 +++++++ .../noxfile.py | 23 +----- ...google.cloud.contactcenterinsights.v1.json | 2 +- ...xup_contact_center_insights_v1_keywords.py | 2 +- .../test_contact_center_insights.py | 72 +++++++++++++------ 14 files changed, 130 insertions(+), 50 deletions(-) diff --git a/packages/google-cloud-contact-center-insights/CONTRIBUTING.rst b/packages/google-cloud-contact-center-insights/CONTRIBUTING.rst index aa972d9de3fb..4be792105a32 100644 --- a/packages/google-cloud-contact-center-insights/CONTRIBUTING.rst +++ b/packages/google-cloud-contact-center-insights/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py index 116bd5746629..64cabec4b64a 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/__init__.py @@ -130,6 +130,7 @@ SilenceData, SmartComposeSuggestionData, SmartReplyData, + SpeechConfig, View, ) @@ -239,5 +240,6 @@ "SilenceData", "SmartComposeSuggestionData", "SmartReplyData", + "SpeechConfig", "View", ) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py index 5f3ada6f8f36..4b68bced5210 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/__init__.py @@ -128,6 +128,7 @@ SilenceData, SmartComposeSuggestionData, SmartReplyData, + SpeechConfig, View, ) @@ -226,6 +227,7 @@ "SilenceData", "SmartComposeSuggestionData", "SmartReplyData", + "SpeechConfig", "UndeployIssueModelMetadata", "UndeployIssueModelRequest", "UndeployIssueModelResponse", diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py index ac3bc60c3fb3..360a0d13ebdd 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py index 4cb3e4748b15..4586b6a2f19a 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/async_client.py @@ -99,6 +99,10 @@ class ContactCenterInsightsAsyncClient: parse_phrase_matcher_path = staticmethod( ContactCenterInsightsClient.parse_phrase_matcher_path ) + recognizer_path = staticmethod(ContactCenterInsightsClient.recognizer_path) + parse_recognizer_path = staticmethod( + ContactCenterInsightsClient.parse_recognizer_path + ) settings_path = staticmethod(ContactCenterInsightsClient.settings_path) parse_settings_path = staticmethod(ContactCenterInsightsClient.parse_settings_path) view_path = staticmethod(ContactCenterInsightsClient.view_path) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py index a5dafefc6ed7..7c0528617444 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/services/contact_center_insights/client.py @@ -352,6 +352,30 @@ def parse_phrase_matcher_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def recognizer_path( + project: str, + location: str, + recognizer: str, + ) -> str: + """Returns a fully-qualified recognizer string.""" + return ( + "projects/{project}/locations/{location}/recognizers/{recognizer}".format( + project=project, + location=location, + recognizer=recognizer, + ) + ) + + @staticmethod + def parse_recognizer_path(path: str) -> Dict[str, str]: + """Parses a recognizer path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/recognizers/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def settings_path( project: str, diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py index b17db47501d1..ecbc4bcf9db9 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/__init__.py @@ -119,6 +119,7 @@ SilenceData, SmartComposeSuggestionData, SmartReplyData, + SpeechConfig, View, ) @@ -226,5 +227,6 @@ "SilenceData", "SmartComposeSuggestionData", "SmartReplyData", + "SpeechConfig", "View", ) diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py index e5953d126498..464613619ccc 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/contact_center_insights.py @@ -360,6 +360,10 @@ class UploadConversationRequest(proto.Message): Optional. DLP settings for transcript redaction. Optional, will default to the config specified in Settings. + speech_config (google.cloud.contact_center_insights_v1.types.SpeechConfig): + Optional. Default Speech-to-Text + configuration. Optional, will default to the + config specified in Settings. """ parent: str = proto.Field( @@ -380,6 +384,11 @@ class UploadConversationRequest(proto.Message): number=4, message=resources.RedactionConfig, ) + speech_config: resources.SpeechConfig = proto.Field( + proto.MESSAGE, + number=11, + message=resources.SpeechConfig, + ) class UploadConversationMetadata(proto.Message): @@ -584,7 +593,9 @@ class IngestConversationsRequest(proto.Message): Attributes: gcs_source (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest.GcsSource): - A cloud storage bucket source. + A cloud storage bucket source. Note that any + previously ingested objects from the source will + be skipped to avoid duplication. This field is a member of `oneof`_ ``source``. transcript_object_config (google.cloud.contact_center_insights_v1.types.IngestConversationsRequest.TranscriptObjectConfig): diff --git a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py index 39b9ceb9fd7d..55e1f740d185 100644 --- a/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py +++ b/packages/google-cloud-contact-center-insights/google/cloud/contact_center_insights_v1/types/resources.py @@ -56,6 +56,7 @@ "ExactMatchConfig", "Settings", "RedactionConfig", + "SpeechConfig", "RuntimeAnnotation", "AnswerFeedback", "ArticleSuggestionData", @@ -1735,6 +1736,11 @@ class Settings(proto.Message): redaction_config (google.cloud.contact_center_insights_v1.types.RedactionConfig): Default DLP redaction resources to be applied while ingesting conversations. + speech_config (google.cloud.contact_center_insights_v1.types.SpeechConfig): + Optional. Default Speech-to-Text resources to + be used while ingesting audio files. Optional, + CCAI Insights will create a default if not + provided. """ class AnalysisConfig(proto.Message): @@ -1806,6 +1812,11 @@ class AnalysisConfig(proto.Message): number=10, message="RedactionConfig", ) + speech_config: "SpeechConfig" = proto.Field( + proto.MESSAGE, + number=11, + message="SpeechConfig", + ) class RedactionConfig(proto.Message): @@ -1833,6 +1844,21 @@ class RedactionConfig(proto.Message): ) +class SpeechConfig(proto.Message): + r"""Speech-to-Text configuration. + + Attributes: + speech_recognizer (str): + The fully-qualified Speech Recognizer resource name. Format: + ``projects/{project_id}/locations/{location}/recognizer/{recognizer}`` + """ + + speech_recognizer: str = proto.Field( + proto.STRING, + number=1, + ) + + class RuntimeAnnotation(proto.Message): r"""An annotation that was generated during the customer and agent interaction. diff --git a/packages/google-cloud-contact-center-insights/noxfile.py b/packages/google-cloud-contact-center-insights/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-contact-center-insights/noxfile.py +++ b/packages/google-cloud-contact-center-insights/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json b/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json index d94d393ac183..c3e9d3df64ac 100644 --- a/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json +++ b/packages/google-cloud-contact-center-insights/samples/generated_samples/snippet_metadata_google.cloud.contactcenterinsights.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-contact-center-insights", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py b/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py index 63cb6b1c4c2b..6c0a0dd4ff19 100644 --- a/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py +++ b/packages/google-cloud-contact-center-insights/scripts/fixup_contact_center_insights_v1_keywords.py @@ -76,7 +76,7 @@ class contact_center_insightsCallTransformer(cst.CSTTransformer): 'update_phrase_matcher': ('phrase_matcher', 'update_mask', ), 'update_settings': ('settings', 'update_mask', ), 'update_view': ('view', 'update_mask', ), - 'upload_conversation': ('parent', 'conversation', 'conversation_id', 'redaction_config', ), + 'upload_conversation': ('parent', 'conversation', 'conversation_id', 'redaction_config', 'speech_config', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py b/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py index da906d57ce8f..720618882f47 100644 --- a/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py +++ b/packages/google-cloud-contact-center-insights/tests/unit/gapic/contact_center_insights_v1/test_contact_center_insights.py @@ -20902,6 +20902,7 @@ def test_update_settings_rest(request_type): "deidentify_template": "deidentify_template_value", "inspect_template": "inspect_template_value", }, + "speech_config": {"speech_recognizer": "speech_recognizer_value"}, } request = request_type(**request_init) @@ -21117,6 +21118,7 @@ def test_update_settings_rest_bad_request( "deidentify_template": "deidentify_template_value", "inspect_template": "inspect_template_value", }, + "speech_config": {"speech_recognizer": "speech_recognizer_value"}, } request = request_type(**request_init) @@ -23587,9 +23589,37 @@ def test_parse_phrase_matcher_path(): assert expected == actual -def test_settings_path(): +def test_recognizer_path(): project = "scallop" location = "abalone" + recognizer = "squid" + expected = ( + "projects/{project}/locations/{location}/recognizers/{recognizer}".format( + project=project, + location=location, + recognizer=recognizer, + ) + ) + actual = ContactCenterInsightsClient.recognizer_path(project, location, recognizer) + assert expected == actual + + +def test_parse_recognizer_path(): + expected = { + "project": "clam", + "location": "whelk", + "recognizer": "octopus", + } + path = ContactCenterInsightsClient.recognizer_path(**expected) + + # Check that the path construction is reversible. + actual = ContactCenterInsightsClient.parse_recognizer_path(path) + assert expected == actual + + +def test_settings_path(): + project = "oyster" + location = "nudibranch" expected = "projects/{project}/locations/{location}/settings".format( project=project, location=location, @@ -23600,8 +23630,8 @@ def test_settings_path(): def test_parse_settings_path(): expected = { - "project": "squid", - "location": "clam", + "project": "cuttlefish", + "location": "mussel", } path = ContactCenterInsightsClient.settings_path(**expected) @@ -23611,9 +23641,9 @@ def test_parse_settings_path(): def test_view_path(): - project = "whelk" - location = "octopus" - view = "oyster" + project = "winkle" + location = "nautilus" + view = "scallop" expected = "projects/{project}/locations/{location}/views/{view}".format( project=project, location=location, @@ -23625,9 +23655,9 @@ def test_view_path(): def test_parse_view_path(): expected = { - "project": "nudibranch", - "location": "cuttlefish", - "view": "mussel", + "project": "abalone", + "location": "squid", + "view": "clam", } path = ContactCenterInsightsClient.view_path(**expected) @@ -23637,7 +23667,7 @@ def test_parse_view_path(): def test_common_billing_account_path(): - billing_account = "winkle" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -23647,7 +23677,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nautilus", + "billing_account": "octopus", } path = ContactCenterInsightsClient.common_billing_account_path(**expected) @@ -23657,7 +23687,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "scallop" + folder = "oyster" expected = "folders/{folder}".format( folder=folder, ) @@ -23667,7 +23697,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "abalone", + "folder": "nudibranch", } path = ContactCenterInsightsClient.common_folder_path(**expected) @@ -23677,7 +23707,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "squid" + organization = "cuttlefish" expected = "organizations/{organization}".format( organization=organization, ) @@ -23687,7 +23717,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "clam", + "organization": "mussel", } path = ContactCenterInsightsClient.common_organization_path(**expected) @@ -23697,7 +23727,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "whelk" + project = "winkle" expected = "projects/{project}".format( project=project, ) @@ -23707,7 +23737,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "octopus", + "project": "nautilus", } path = ContactCenterInsightsClient.common_project_path(**expected) @@ -23717,8 +23747,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "oyster" - location = "nudibranch" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -23729,8 +23759,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "cuttlefish", - "location": "mussel", + "project": "squid", + "location": "clam", } path = ContactCenterInsightsClient.common_location_path(**expected)